UIKit框架 - 06.UIActionSheet使用

1.UIAcitonSheet概述

  • 有时候我们希望提示框或弹窗能从底部弹出,苹果耶提供了这么一个类来实现这个功能
  • 功能显示
  • 这里写图片描述

2.代码实现

  • 这里我们实现基本功能,点击屏幕弹框出现,点击按钮,弹框消失
  • 弹框上设置了3个按钮
  • 注意:与UIAlertView类不同,UIAcitonSheet不能添加文本框
-(void)touchesBegan:(nonnull NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event{
    // 1.创建UIActionSheet
    UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"哥是标题" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确认" otherButtonTitles:@"Other", nil];
// 2.显示到视图上
    [sheet showInView:self.view];
}

// 监听按钮点击事件
// 只要UIActionSheet上的按钮被点击就会调用
// actionSheet:谁触发事件就会把谁传递进来
// clickedButtonAtIndex:当前被点击按钮的索引
#pragma mark - UIActionSheetDelegate
-(void)actionSheet:(nonnull UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    // 0.确认按钮,Other是取消按钮,2是取消按钮
    NSLog(@"%ld被点击了",buttonIndex);

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值