1.UIAcitonSheet概述
- 有时候我们希望提示框或弹窗能从底部弹出,苹果耶提供了这么一个类来实现这个功能
- 功能显示
![这里写图片描述](https://img-blog.csdn.net/20150713214520605)
2.代码实现
- 这里我们实现基本功能,点击屏幕弹框出现,点击按钮,弹框消失
- 弹框上设置了3个按钮
- 注意:与UIAlertView类不同,UIAcitonSheet不能添加文本框
-(void)touchesBegan:(nonnull NSSet<UITouch *> *)touches withEvent:(nullable UIEvent *)event{
UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"哥是标题" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确认" otherButtonTitles:@"Other", nil];
[sheet showInView:self.view];
}
#pragma mark - UIActionSheetDelegate
-(void)actionSheet:(nonnull UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%ld被点击了",buttonIndex);
}