美文网首页iOS 基础知识
UIAlertController与UIAlertAction的

UIAlertController与UIAlertAction的

作者: 流年忆时光 | 来源:发表于2017-04-18 16:00 被阅读116次

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];


相关文章

网友评论

    本文标题:UIAlertController与UIAlertAction的

    本文链接:https://www.haomeiwen.com/subject/yetqzttx.html