preferredStyle是个枚举类型
typedef NS_ENUM(NSInteger, UIAlertControllerStyle) {
UIAlertControllerStyleActionSheet = 0,该状态是类似于(UIAlertView)
UIAlertControllerStyleAlert 该状态是UIActionSheet(从底部弹出来的弹窗)
}
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"升级提示"message:@"温馨提示" preferredStyle:UIAlertControllerStyleActionSheet];
[alert addAction:[UIAlertAction actionWithTitle:@"相机" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action)
{
NSLog(@"点击现在升级按钮");
}]];
[alert addAction:[UIAlertAction actionWithTitle:@"相册" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action)
{
NSLog(@"点击下次再说按钮");
}]];
[self presentViewController:alert animated:YES completion:nil];
网友评论