UIAlertController与UIAlertAction的使用


1 给系统的UIAlertController的外边框更改颜色和线宽

谨记 :

如何要显示出警告框 和以往的show不同 要使用presentViewController 弹出

[self presentViewController:ac animated:true completion:nil];

更改颜色是要转成CGColor


代码如下:


UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"友情提示" message:@"哈哈哈" preferredStyle:UIAlertControllerStyleAlert];

//更改边框颜色

ac.view.layer.borderColor = [UIColor redColor].CGColor;

//更改边框线条粗细

ac.view.layer.borderWidth = 5.0f;

//更改其背景色

ac.view.layer.backgroundColor = [UIColor yellowColor].CGColor;

UIAlertAction *ala1 = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

NSLog(@"1111的实现方法");

}];

UIAlertAction *ala2 = [UIAlertAction actionWithTitle:@"跳转" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

NSLog(@"2222的实现方法");

}];

UIAlertAction *ala3 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {

NSLog(@"3333的实现方法");

}];

[ac addAction:ala1];

[ac addAction:ala2];

[ac addAction:ala3];

//显示弹框

[self presentViewController:ac animated:true completion:nil];


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容