弹窗的几种方式

弹窗的几种方式 (苹果原生)

  • UIAlertView : 从中间弹出来(9.0以后过期了)

806461-20151121162621983-971076795.png

  • 实现代码如下:
// 方式一:(9.0过期了)

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"BabyWong的标题" message:@"BabyWong的内容" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];

    // 一定要调用show方法
    [alertView show];
  • UIActionSheet : 从底部弹出来(9.0以后过期了)

806461-20151121162639968-875606099.png

  • 实现代码如下:
 // 方式二:(9.0过期了)
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"BabyWong的标题" delegate:nil cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:@"其他", nil];

    // 一定要调用show方法
    [sheet showInView:self];
  • UIAlertController == UIAlertView + UIActionSheet 主流弹窗方式8.0开始可以使用,更灵活,,可以选择弹窗样式(中间 / 底部)

806461-20151121162719765-1690853076.png

  • 实现代码如下:

   UIAlertController *controller = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

    [controller addAction:[UIAlertAction actionWithTitle:@"收藏" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        WWLog(@"点击了收藏按钮");
    }]];

     [controller addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
         WWLog(@"取消");
     }]];

    [controller addAction:[UIAlertAction actionWithTitle:@"举报" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
        WWLog(@"点击了[举报]按钮");
    }]];

// 一定要手动modal出来
    [self.window.rootViewController presentViewController:controller animated:YES completion:nil];
  • Posted by 博客园·BabyWong
  • 原创文章,版权声明:自由转载-非商用-非衍生-保持署名BabyWong
  • 邮箱 wenmeiwong520@gmail.com

转载于:https://www.cnblogs.com/WMHaa/p/4983984.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值