官方公開的屬性辈赋,并不多鲫忍,貌似可以定制的東西很有限,但是钥屈,我們不能忽略的是UIAlertController是繼承與UIViewController的悟民,我們很容易聯(lián)想到UIViewController的一些特征和屬性,最簡單的一點就是UIViewController有一個View篷就,我們可以給View加?xùn)|西射亏。 既然如此,那就去加?xùn)|西竭业。
實例代碼如下
(void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
button.backgroundColor = [UIColor yellowColor];
[button addTarget:self action:@selector(buttonClick) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
}-
(void)buttonClick
{
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"沒有標(biāo)題的標(biāo)題"
message:@"學(xué)無止境智润,漫漫長路"
preferredStyle:UIAlertControllerStyleAlert ];//添加取消到UIAlertController中
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:cancelAction];//添加確定到UIAlertController中
UIAlertAction *OKAction = [UIAlertAction actionWithTitle:@"確定" style:UIAlertActionStyleDefault handler:nil];
[alertController addAction:OKAction];UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake(10, 20, 30, 30)];
imageView2.image = [UIImage imageNamed:@"WechatIMG20"];
[alertController.view addSubview:imageView2];[self presentViewController:alertController animated:YES completion:nil];
}
對你有幫助的話,點個贊吧??