iOS 8中的ActionSheet

时间:2014-10-23 04:55:10

标签: objective-c iphone ipad ios8 uialertcontroller

如何在iOS 8中UIAlertController ActionSheet设置标题背景颜色?

以下代码是我尝试过的。但我不知道设置ActionSheet的标题颜色。

- (IBAction)bt2Clicked:(UIButton *)sender {

// Action sheet style.
   UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Evacuate Building!" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];

__weak ViewController *wself = self;

UIAlertAction *destructiveAction = [UIAlertAction actionWithTitle:@"Kick through door" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
    __strong ViewController *sself = wself;
    sself.actionResponseLabel.text = @"Careful!";
}];

UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Walk calmly" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
    __strong ViewController *sself = wself;
    sself.actionResponseLabel.text = @"Find nearest exit.";
}];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Do nothing" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    __strong ViewController *sself = wself;
    sself.actionResponseLabel.text = @"Just relax";
}];


[actionSheet addAction:destructiveAction];
[actionSheet addAction:defaultAction];
[actionSheet addAction:cancelAction];
actionSheet.view.tintColor = [UIColor blackColor];

UIColor *customTitleColor=[UIColor colorWithRed:(0.0/255.0) green:(159.0/255.0) blue:(196.0/255.0) alpha:1.0];         //  **I need to set this colour to title.** 

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

}

0 个答案:

没有答案
相关问题