在iOS8中自定义UIAlertController

在iOS8中自定义UIAlertController,ios,uialertcontroller,Ios,Uialertcontroller,在iOS8中,UIAlertView已被弃用。我们应该使用UIAlertController。 我想定制它,比如字体颜色,alertcontrller视图消息标签的字体系列,还想更改ok按钮的背景颜色。我不知道正确的方法 请帮忙 任何帮助都是值得感激的 马特·汤普森的网站上有一个非常好的教程: 另外,如何在iOS开发者库上配置警报: 我想,你一直在和他们一起执行任务。但我认为这对某人很有用 下面的代码完全符合我的要求。请根据您的要求进行更改 UIAlertController *alertCo

在iOS8中,
UIAlertView
已被弃用。我们应该使用
UIAlertController
。 我想定制它,比如字体颜色,alertcontrller视图消息标签的字体系列,还想更改ok按钮的背景颜色。我不知道正确的方法

请帮忙


任何帮助都是值得感激的

马特·汤普森的网站上有一个非常好的教程:

另外,如何在iOS开发者库上配置警报:


我想,你一直在和他们一起执行任务。但我认为这对某人很有用

下面的代码完全符合我的要求。请根据您的要求进行更改

UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil
                                                                         message:nil
                                                                  preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction *setCoverPhoto = [UIAlertAction
                                actionWithTitle:@"First Button"
                                style:UIAlertActionStyleDefault
                                handler:^(UIAlertAction *action){

                                    NSLog(@"First Button");

                                }];
[alertController addAction:setCoverPhoto];


UIAlertAction *deleteImageAct = [UIAlertAction
                                 actionWithTitle:@"Second Button"
                                 style:UIAlertActionStyleDefault
                                 handler:^(UIAlertAction *action) {

                                     NSLog(@"Second Button");

                                 }];
[alertController addAction:deleteImageAct];

UIAlertAction *setImageASNotif = [UIAlertAction
                                  actionWithTitle:@"Third Button"
                                  style:UIAlertActionStyleDefault
                                  handler:^(UIAlertAction *action) {

                                      NSLog(@"Third Button");

                                  }];
[alertController addAction:setImageASNotif];


alertController.view.tintColor = [UIColor whiteColor];

UIView *subView = alertController.view.subviews.firstObject;
UIView *alertContentView = subView.subviews.firstObject;
[alertContentView setBackgroundColor:[UIColor darkGrayColor]];

alertContentView.layer.cornerRadius = 5;

[self presentViewController:alertController animated:YES completion:nil];

s您可以自定义uialert,您需要在子视图中循环,并根据您的要求进行更改…请展示您的,不要空白询问如何…耶,谢谢!但是没有比循环更好的解决方案吗?或者你可以对控件进行子类化,或者直接使用自定义视图在IOS8Thank@Steve Rosenberg中尝试我的UIAlertController代码。但是你能给我Objective-C的链接吗。当然,苹果网站是在Obj C和SWIFT中,这不会改变OK按钮的背景色此处讨论的颜色:@CarouselMin有没有办法改变OK按钮的背景色?