cdts/xdts-ios 3/TreeHole/Code/Utility/MTActionSheet/MTActionSheet.h

50 lines
1.6 KiB
C
Raw Normal View History

2023-07-27 09:20:00 +08:00
//
// MTActionSheet.h
// Meet
//
// Created by ko1o, on 2018/10/16.
// Copyright © 2018年 Food. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef NS_ENUM(NSUInteger, MTActionSheetButtonType) {
MTActionSheetButtonTypeNormal,
MTActionSheetButtonTypeCancel,
MTActionSheetButtonTypeDestructive,
};
@class MTActionSheet;
@interface MTActionSheetButton : UIButton
+ (instancetype)buttonWithType:(MTActionSheetButtonType)type title:(NSString *)title;
@end
@protocol MTActionSheetDelegate <NSObject>
@optional
// Called when a button is clicked. The view will be automatically dismissed after this call returns
- (void)actionSheet:(MTActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex;
- (void)actionSheetDidDismiss:(MTActionSheet *)actionSheet; //完全消失后回调,比如点击空白区域消失的情况
@end
@interface MTActionSheet : UIView
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, weak) id<MTActionSheetDelegate> delegate;
- (instancetype)initWithTitle:(nullable NSString *)title delegate:(nullable id<MTActionSheetDelegate>)delegate cancelButtonTitle:(nullable NSString *)cancelButtonTitle destructiveButtonTitle:(nullable NSString *)destructiveButtonTitle otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
- (NSInteger)addButtonWithTitle:(nullable NSString *)title; // returns index of button. 0 based.
- (void)show;
- (void)showInView:(UIView *)view;
- (void)dismiss;
@property (nonatomic, strong) void(^onDidDismiss)(MTActionSheet *sheet);
@property (nonatomic, strong) void(^onClickAction)(MTActionSheet *sheet, NSInteger buttonIndex);
@end