- (instancetype)initwithtitle:(nsstring *)title delegate:(id<uiactionsheetdelegate>)delegate cancelbuttontitle:(nsstring *)cancelbuttontitle destructivebuttontitle:(nsstring *)destructivebuttontitle otherbuttontitles:(nsstring *)otherbuttontitles, ...;
参数说明:
title:视图标题
delegate:设置代理
cancelbuttontitle:取消按钮的标题
destructivebuttontitle:特殊标记的按钮的标题
otherbuttontitles:其他按钮的标题
@property(nonatomic,copy) nsstring *title;
设置标题
@property(nonatomic) uiactionsheetstyle actionsheetstyle;
设置风格,枚举如下:
<a href="http://my.oschina.net/u/2340880/blog/409907#">?</a>
1
2
3
4
5
6
<code>typedef</code> <code>ns_enum(nsinteger, uiactionsheetstyle) {</code>
<code> </code><code>uiactionsheetstyleautomatic = -1, </code>
<code> </code><code>uiactionsheetstyledefault = uibarstyledefault,</code>
<code> </code><code>uiactionsheetstyleblacktranslucent = uibarstyleblacktranslucent,</code>
<code> </code><code>uiactionsheetstyleblackopaque = uibarstyleblackopaque,</code>
<code>};</code>
- (nsinteger)addbuttonwithtitle:(nsstring *)title;
添加一个按钮,会返回按钮的索引
- (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;
使用代码将视图收回
- (void)actionsheet:(uiactionsheet *)actionsheet clickedbuttonatindex:(nsinteger)buttonindex;
点击按钮时触发的方法
- (void)willpresentactionsheet:(uiactionsheet *)actionsheet;
视图将要弹出时触发的方法
- (void)didpresentactionsheet:(uiactionsheet *)actionsheet;
视图已经弹出式触发的方法
- (void)actionsheet:(uiactionsheet *)actionsheet willdismisswithbuttonindex:(nsinteger)buttonindex;
点击按钮后,视图将要收回时触发的方法
- (void)actionsheet:(uiactionsheet *)actionsheet diddismisswithbuttonindex:(nsinteger)buttonindex;
点击按钮后,视图已经收回时触发的方法