400行代码实现的简易UIAlertView,添加动画,虚化效果。接口文件中没有对视图的更多的视图属性开放接口,使用过程中可以根据自己的需求进行自定义接口。
与系统UIAlertView的初始化、显示、委托方法相同,多添加动画接口animationOption
NS_ASSUME_NONNULL_BEGIN
typedef NS_OPTIONS(NSUInteger, STAlertAnimationOptions) {
STAlertAnimationOptionNone = 1 << 0,
STAlertAnimationOptionZoom = 1 << 1, // 先放大,再缩小,在还原
STAlertAnimationOptionTopToCenter = 1 << 2, // 从上到中间
};
@protocol STAlertViewDelegate;
@class UILabel, UIButton, UIWindow;
@interface STAlertView : UIView
- (instancetype)initWithTitle:(nullable NSString *)title message:(nullable NSString *)message delegate:(nullable id <STAlertViewDelegate>)delegate cancelButtonTitle:(nullable NSString *)cancelButtonTitle otherButtonTitles:(nullable NSString *)otherButtonTitles, ... NS_REQUIRES_NIL_TERMINATION;
// shows popup alert animated.
- (void)show;
@property(nullable,nonatomic,weak)id <STAlertViewDelegate> delegate;
@property(nonatomic)STAlertAnimationOptions animationOption;
@end
@protocol STAlertViewDelegate <NSObject>
@optional
// Called when a button is clicked. The view will be automatically dismissed after this call returns
- (void)alertView:(STAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
@end
NS_ASSUME_NONNULL_END
- 支持iOS8以上
- 添加动画,Zoom和TopToCenter动画
- 支持虚化背景