-
Notifications
You must be signed in to change notification settings - Fork 4
iOS AlertView背景设置为不透明
zyfoolboy edited this page Mar 31, 2016
·
1 revision
最近做的项目用到AlertView提示框,iOS8之前UIAlertView自带的提示框是半透明的,并且没有办法改正。产品硬性要求AlertView提示框背景为不透明,设置AlertView的alpha为1.0没有效果<br>
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:nil
message:str
delegate:self
cancelButtonTitle:@"确定"
otherButtonTitles:nil];
alertview.view.alpha = 1.0;
[alertView show];
之后我就尝试用UIAlertViewController,因为UIAlertView在iOS8之后被替换了,在这里设置alertview的视图alpha之后效果出现了,不过提示框变为直角的了,加上一句代码就OK了
UIAlertController *alertview=[UIAlertController alertControllerWithTitle:nil message:str preferredStyle:UIAlertControllerStyleAlert];
// UIAlertControllerStyleActionSheet 是显示在屏幕底部
// UIAlertControllerStyleAlert 是显示在中间
alertview.view.alpha = 1.0;
alertview.view.layer.cornerRadius = 10;
// 设置按钮
UIAlertAction *cancel=[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleCancel handler:nil];
[alertview addAction:cancel];
[self presentViewController:alertview animated:YES completion:nil];