3
A
回答
6
这是从另一个堆栈溢出帖子,但似乎工作正常。 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:霍根forKey:@ “attributedTitle”];
[hogan addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0,35)];
+0
而且你会得到一个崩溃试图设置一些ios版本的未定义键值(不要r emember)。您还必须为您要设置图像的UIAlertAction重写'setValue:forUndefinedKey:'和'valueForUndefinedKey:'。 – vahotm 2017-11-09 12:06:21
4
改变颜色UIAlertController
SEL selector = NSSelectorFromString(@"_alertController");
if ([actionSheet respondsToSelector:selector])
{
UIAlertController *alertController = [actionSheet valueForKey:@"_alertController"];
if ([alertController isKindOfClass:[UIAlertController class]])
{
NSArray *arr = alertController.actions;
for (int i = 0; i <arr.count; i ++) {
UIAlertAction *alertAction = [arr objectAtIndex:i];
if ([alertAction.title isEqualToString:@"Logout"]) {
UIColor *color = [UIColor redColor];
[alertAction setValue:color forKey:@"titleTextColor"];
}
}
}
0
一个动作我无法改变字体,但你可以改变字体颜色。从'霍根例如,改变上UIAlertAction字体颜色:
[button setValue:[UIColor greenColor] forKey:@"titleTextColor"];
1
只需做这样
UIAlertAction * action = [UIAlertAction actionWithTitle:@"ACTION TITLE" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
// TODO : ACTION
}];
[action setValue:[UIColor redColor] forKey:@"titleTextColor"];
[alertController action];
相关问题
- 1. 改变字体大小和颜色aspx.net
- 2. Xamarin.Forms:更改图表的字体大小和字体颜色
- 3. 如何更改Plotyy的Seond轴的颜色和字体大小?
- 4. 如何更改android通知颜色和字体大小?
- 5. 如何在C#中更改窗体的颜色和大小?
- 6. 如何从Java文件更改字体大小和字体颜色?
- 7. 如何更改javascript计算的字体,颜色,大小等?
- 8. 如何更改textView文本程序的字体/大小/颜色?
- 9. 如何修改轴文本煎茶图字体颜色和字体大小
- 10. 如何更改我的颜色条上基础和指数的字体大小?
- 11. 更改UISegment控件的字体颜色和大小
- 12. 如何更改字体,颜色,大小,...使用javascript
- 13. Emailer字体颜色和大小问题
- 14. UILabel字体大小和颜色不会改变
- 15. 如何更改Telerik MVC Chart标题的字体大小和颜色?
- 16. 如何更改material2 md输入占位符的字体大小和颜色?
- 17. 如何动态更改字体颜色?
- 18. 更改tabbar的大小和颜色iphone
- 19. 更改qwtSlider的颜色和大小
- 20. 如何配置Msys的默认大小,颜色和字体?
- 21. 如何设置导航栏的字体颜色和大小
- 22. 如何更改列表视图上的颜色和字体
- 23. 如何更改字体颜色。 - Python的
- 24. 如何更改GridView的字体颜色?
- 25. 如何更改ListView的字体颜色
- 26. 如何更改textView的字体颜色
- 27. 如何在Wijmo5中更改图表标题大小和颜色
- 28. Seaborn,更改颜色条的字体大小
- 29. 更改ListView阴影颜色和大小
- 30. 如何更改多色彩字形的颜色(图标字体)
[UIAlertController自定义字体,大小,颜色](HTTP的可能重复://计算器。 com/questions/26460706/uialertcontroller-custom-font-size-color) – picciano 2015-04-03 17:59:14
检查此解决方案http://stackoverflow.com/a/27518769/2050181 – 2015-12-02 11:46:07
检查此解决方案http://stackoverflow.com/questions/26460706/uialertcontroller - 自定义字体大小的颜色/ 41299305#41299305 – 2016-12-23 10:56:25