gpt4 book ai didi

ios - 如何在 UIAlertController 中更改 UIAlertAction 的字体大小和颜色

转载 作者:可可西里 更新时间:2023-11-01 06:20:04 32 4
gpt4 key购买 nike

enter image description here

上图中“Done”、“Some Other action”如何改变字体大小和颜色?以及如何更改“title”和“message”的字体大小和颜色?

谢谢。

最佳答案

这是来自另一个堆栈溢出帖子,但似乎工作正常。 Post found here.

UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Dont care what goes here, since we're about to change below" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"Presenting the great... Hulk Hogan!"];
[hogan addAttribute:NSFontAttributeName
value:[UIFont systemFontOfSize:50.0]
range:NSMakeRange(24, 11)];
[alertVC setValue:hogan forKey:@"attributedTitle"];



UIAlertAction *button = [UIAlertAction actionWithTitle:@"Label text"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction *action){
//add code to make something happen once tapped
}];
UIImage *accessoryImage = [UIImage imageNamed:@"someImage"];
[button setValue:accessoryImage forKey:@"image"];

要使用以下内容更改文本的颜色,请将其添加到行设置之前[alertVC setValue:hogan forKey:@"attributedTitle"];

[hogan addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0,35)];

关于ios - 如何在 UIAlertController 中更改 UIAlertAction 的字体大小和颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29382034/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com