UIActionSheet是在iOS弹出的选择按钮项,可以添加多项,并为每项添加点击事件。
-(IBAction)sheetshow:(id)sender{
UIActionSheet *sheetnow=[[UIActionSheet alloc]initWithTitle:@"相片设置功能" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"相片移除" otherButtonTitles:@"确认", nil];
[sheetnow showInView:self.view];
}
//代理
<UIActionSheetDelegate>
//代理方法-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
NSLog(@"%ld",buttonIndex);
if (buttonIndex==1) {
UIImageView *view=[[UIImageView alloc]initWithFrame:self.view.frame];
view.backgroundColor=[UIColor blackColor];
[self.view addSubview:view];
}
}