一款简约而不失强大的 ActionSheet,微博、微信和 QQ 都采用了极其类似的样式,完全支持 Swift。
添加属性来控制 title 的 numberOfLines,#45 by iOSleep:
@interface LCActionSheetConfig : NSObject
// Title can be limit in titleLinesNumber. Default is 0.
@property (nonatomic, assign) NSInteger titleLinesNumber;
@end
@interface LCActionSheet : UIView
// Title can be limit in titleLinesNumber. Default is 0.
@property (nonatomic, assign) NSInteger titleLinesNumber;
@end
思来想去,还是恢复了“黑”状态栏的样式。现在 LCActionSheet 实例将会在调用 show
方法时,新建一个 UIWindow 实例并 makeKeyAndVisible
,然后把 LCActionSheet 实例添加到该 UIWindow 实例之上。之前的逻辑是直接把 LCActionSheet 实例添加到 AppDelegate 的 keyWindow 上面。显然的,现在状态栏将被会灰色背景一块“黑”掉。
新增下列方法,didDismiss
回调能很方便地满足在 LCActionSheet hide 时,需要在原 keyWindow 上操作的需求:
@interface LCActionSheet : UIView
// Initialize an instance of LCActionSheet (Block).
+ (instancetype)sheetWithTitle:(nullable NSString *)title
cancelButtonTitle:(nullable NSString *)cancelButtonTitle
didDismiss:(nullable LCActionSheetDidDismissHandler)didDismissHandler
otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
// Initialize an instance of LCActionSheet with title array (Block).
+ (instancetype)sheetWithTitle:(nullable NSString *)title
cancelButtonTitle:(nullable NSString *)cancelButtonTitle
didDismiss:(nullable LCActionSheetDidDismissHandler)didDismissHandler
otherButtonTitleArray:(nullable NSArray<NSString *> *)otherButtonTitleArray;
// Initialize an instance of LCActionSheet (Block).
- (instancetype)initWithTitle:(nullable NSString *)title
cancelButtonTitle:(nullable NSString *)cancelButtonTitle
didDismiss:(nullable LCActionSheetDidDismissHandler)didDismissHandler
otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
// Initialize an instance of LCActionSheet with title array (Block).
- (instancetype)initWithTitle:(nullable NSString *)title
cancelButtonTitle:(nullable NSString *)cancelButtonTitle
didDismiss:(nullable LCActionSheetDidDismissHandler)didDismissHandler
otherButtonTitleArray:(nullable NSArray<NSString *> *)otherButtonTitleArray;
@end
新增属性:
@interface LCActionSheetConfig : NSObject
// LCActionSheetConfig shared instance.
@property (class, nonatomic, strong, readonly) LCActionSheetConfig *config;
@end
下列方法已不推荐使用,建议使用新的属性代替:
@interface LCActionSheetConfig : NSObject
// LCActionSheetConfig shared instance.
+ (instancetype)shared __deprecated_msg("Method deprecated. Use property `config` instead.");
@end
新增属性和方法:
@interface LCActionSheet : UIView
// Auto hide when the device rotated. Default is NO, won't auto hides.
@property (nonatomic, assign) BOOL autoHideWhenDeviceRotated;
// Append button at index with title.
- (void)appendButtonWithTitle:(nullable NSString *)title atIndex:(NSUInteger)index;
// Append buttons at indexes with titles.
- (void)appendButtonsWithTitles:(NSArray<NSString *> *)titles atIndexes:(NSIndexSet *)indexes;
@end
修改属性类型:
@interface LCActionSheet : UIView
@property (nullable, nonatomic, strong) NSSet<NSNumber *> *destructiveButtonIndexSet;
// ->
@property (nullable, nonatomic, strong) NSIndexSet *destructiveButtonIndexSet;
@end
修改方法命名:
@interface LCActionSheet : UIView
- (void)appendButtonTitles:(nullable NSString *)buttonTitles, ... NS_REQUIRES_NIL_TERMINATION;
// ->
- (void)appendButtonsWithTitles:(nullable NSString *)titles, ... NS_REQUIRES_NIL_TERMINATION;
@end
更正方法命名:
*Handle -> *Handler
如:
LCActionSheetClickedHandle -> LCActionSheetClickedHandler
调整警示按钮默认颜色:
RGB(255, 10, 10) -> RGB(254, 67, 37)