简单使用UIAlertController修改背景颜色
//
// ViewController.m
// UIAlertController
//
// Created by hhg on 15/10/21.
// Copyright (c) 2015年 hhg. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (IBAction)click:(id)sender {
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"是否把背景颜色改成蓝色" preferredStyle:UIAlertControllerStyleAlert];
//取消按钮
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
NSLog(@"取消");
}];
[alertController addAction:cancel];
//确定按钮
__weak ViewController * selfweak = self;
UIAlertAction *sure = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
NSLog(@"确定");
selfweak.view.backgroundColor = [UIColor blueColor];
}];
[alertController addAction:sure];
[self presentViewController:alertController animated:YES completion:nil];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end