IAlertController中更改UIAlertAction

IAlertController中更改UIAlertAction

本文介绍了如何在UIAlertController中更改UIAlertAction的字体大小和颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在上图中如何更改字体大小和颜色完成,其他一些行动?
以及如何更改标题和消息的字体大小和颜色?

In the image above how to change the font size and color of "Done", "Some Other action"?and how to change the font size and color of "title", and "message"?

谢谢。

推荐答案

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

This is from another stack overflow post but seems to work fine. 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:@attributionTitle];

To change the color of the text with the following, adding it before the line setting[alertVC setValue:hogan forKey:@"attributedTitle"];

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

这篇关于如何在UIAlertController中更改UIAlertAction的字体大小和颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 17:58