用法用例:
复制代码
mySheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
常用方法和属性
显示ActionSheet方法:
1.在一个视图内部显示,可以用showInView
[mySheet showInView:self];
2.如果要将ActonSheet 与工具栏或者标签栏对齐,可以使用showFromToolBar或showFromTabBar
复制代码
[mySheet showFromToolBar:toolbar];
[mySheet showFromTabBar:tabbar];
解除操作表单
用户按下按钮之后,Actionsheet就会消失——除非应用程序有特殊原因,需要用户按下做个按钮。用dismiss方法可令表单消失:
[mySheet dismissWithClickButtonIndex:1 animated:YES];
@property(nonatomic,copy) NSString *title;
设置标题
复制代码@property(nonatomic) UIActionSheetStyle actionSheetStyle;
添加一个按钮,会返回按钮的索引
复制代码
- (NSInteger)addButtonWithTitle:(NSString *)title;
[/code]
获取按钮标题
复制代码- (NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;
获取按钮数量
复制代码@property(nonatomic,readonly) NSInteger numberOfButtons;
设置取消按钮的索引值
复制代码@property(nonatomic) NSInteger cancelButtonIndex;
设置特殊标记
复制代码@property(nonatomic) NSInteger destructiveButtonIndex;
视图当前是否可见
复制代码@property(nonatomic,readonly,getter=isVisible) BOOL visible;
下面是几种弹出方式,会根据风格不同展现不同的方式:
复制代码
- (void)showFromToolbar:(UIToolbar *)view;
- (void)showFromTabBar:(UITabBar *)view;
- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated ;
- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated ;
- (void)showInView:(UIView *)view;
使用代码将视图收回
复制代码- (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
UIActionSheet代理方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex;
点击按钮时触发的方法
复制代码
- (void)willPresentActionSheet:(UIActionSheet *)actionSheet;
视图将要弹出时触发的方法










