美文网首页
UIActionSheet

UIActionSheet

作者: Xl_Lee | 来源:发表于2021-02-20 17:28 被阅读0次
    @protocol UIActionSheetDelegate;
    // iOS 2.0 - iOS 8.3可用 使用UIAlertController顶替
    NS_CLASS_DEPRECATED_IOS(2_0, 8_3, "UIActionSheet is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet instead") __TVOS_PROHIBITED
    @interface UIActionSheet : UIView
    
    // 初始化设置标题、代理、操作按钮
    - (instancetype)initWithTitle:(nullable NSString *)title delegate:(nullable id<UIActionSheetDelegate>)delegate cancelButtonTitle:(nullable NSString *)cancelButtonTitle destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION NS_EXTENSION_UNAVAILABLE_IOS("Use UIAlertController instead.");
    // 代理
    @property(nullable,nonatomic,weak) id<UIActionSheetDelegate> delegate;
    // 标题属性
    @property(nonatomic,copy) NSString *title;
    // 操作栏的风格
    @property(nonatomic) UIActionSheetStyle actionSheetStyle; // default is UIActionSheetStyleAutomatic.
    // 在操作栏中添加自定义按钮
    - (NSInteger)addButtonWithTitle:(nullable NSString *)title;
    // 返回指定索引按钮的标题
    - (nullable NSString *)buttonTitleAtIndex:(NSInteger)buttonIndex;
    // 操作栏的按钮数
    @property(nonatomic,readonly) NSInteger numberOfButtons;
    // 取消按钮的下标
    @property(nonatomic) NSInteger cancelButtonIndex;
    // 破坏那妞的下标
    @property(nonatomic) NSInteger destructiveButtonIndex;
    // 第一个更多按钮的下标
    @property(nonatomic,readonly) NSInteger firstOtherButtonIndex;
    // 接收器是否显示
    @property(nonatomic,readonly,getter=isVisible) BOOL visible;
    // 显示一个来自指定工具栏的操作栏
    - (void)showFromToolbar:(UIToolbar *)view;
    // 显示一个来自指定标签栏的操作栏
    - (void)showFromTabBar:(UITabBar *)view;
    // 显示一个来自指定BarButtonItem的操作栏
    - (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated NS_AVAILABLE_IOS(3_2);
    // 显示一个来自指定矩形的操作栏
    - (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated NS_AVAILABLE_IOS(3_2);
    // 显示一个来自指定视图的操作栏
    - (void)showInView:(UIView *)view;
    
    // 隐藏弹出框
    - (void)dismissWithClickedButtonIndex:(NSInteger)buttonIndex animated:(BOOL)animated;
    
    @end
    
    
    __TVOS_PROHIBITED
    @protocol UIActionSheetDelegate <NSObject>
    @optional
    
    // 点击按钮操作调用
    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;
    
    // 点击取消操作按钮调用
    - (void)actionSheetCancel:(UIActionSheet *)actionSheet NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;
    // 即将弹出操作栏之前调用
    - (void)willPresentActionSheet:(UIActionSheet *)actionSheet NS_DEPRECATED_IOS(2_0, 8_3)__TVOS_PROHIBITED;
    // 操作栏弹出后调用
    - (void)didPresentActionSheet:(UIActionSheet *)actionSheet NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;
    // 操作后将要隐藏的操作栏时调用
    - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;
    // 操作栏隐藏完成后调用
    - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex NS_DEPRECATED_IOS(2_0, 8_3) __TVOS_PROHIBITED;  // after animation
    
    @end
    
    // 操作栏风格
    typedef NS_ENUM(NSInteger, UIActionSheetStyle) {
    UIActionSheetStyleAutomatic        = -1,       // take appearance from toolbar style otherwise uses 'default'
    UIActionSheetStyleDefault          = UIBarStyleDefault, // 默认
    UIActionSheetStyleBlackTranslucent = UIBarStyleBlackTranslucent, // 半透明黑色
    UIActionSheetStyleBlackOpaque      = UIBarStyleBlackOpaque , // 不透明黑色
    } __TVOS_PROHIBITED;
    

    相关文章

      网友评论

          本文标题:UIActionSheet

          本文链接:https://www.haomeiwen.com/subject/bcatfltx.html