大佬教程收集整理的这篇文章主要介绍了ios – UIAlertController和UIAlertControllerStyleActionSheet自定义,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我知道这是可行的:
(这正是我正在寻找的)
我搜索了几个小时,但我在互联网上找不到任何可以帮助我完成这个简单任务的tut.另外,由于UIActionSheet自IOS 9以来已被弃用,因此无论何时我尝试找到解决方案,它都不再可用.另外,我读到UIAlertController不打算被子类化……
有谁知道如何轻松定制我的警报?
我是否必须将uIView子类化为自己的警报表?
首先,您必须创建一个UIAlertController
UIAlertController *alertVC = [UIAlertController alertControllerWithtitle:@"Alert title" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];
自定义字体!即使只是某些角色.
NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"PresenTing the great... StackOverFlow!"]; [hogan addAttribute:NSFontAttributENAME value:[UIFont systemFontOfSize:30.0] range:NsmakeRange(24,11)]; [alertVC @R_489_6938@ue:hogan forKey:@"attributedtitle"];
现在,让我们创建一个UIAlertAction,您可以在其中添加动作处理程序并添加图标.
UIAlertAction *button = [UIAlertAction actionWithtitle:@"First Button" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ //add code to make something happen once tapped }]; UIAlertAction *button2 = [UIAlertAction actionWithtitle:@"Second Button" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action){ //add code to make something happen once tapped }];
在这里,您将图标添加到AlertAction.对我来说,你必须指定UIImageRenderingModeAlwaysOriginal
[button @R_489_6938@ue:[[UIImage imagenamed:@"image.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forKey:@"image"]; [alertVC addAction:button2]; [alertVC addAction:button];
记得要呈现ViewController
[self presentViewController:alertVC animated:YES completion:nil];
以上是大佬教程为你收集整理的ios – UIAlertController和UIAlertControllerStyleActionSheet自定义全部内容,希望文章能够帮你解决ios – UIAlertController和UIAlertControllerStyleActionSheet自定义所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。