• 现在包含您请求的多个按钮功能 :)
• 现已发布在 Cocoapods 上的 AMSmoothAlert
我在 Dribbble 上看到了这个非常酷的弹出视图构想,所以我决定重现它!
(上面的 gif 比实际的速度动画慢)
AMSmoothAlertView *alert = [[AMSmoothAlertView alloc]initWithTitle:@"Congrats !"
andText:@"You've just displayed this awesome alert view !"
forAlertType:AlertSuccess];
主要方法
//initialisation with a Title and a Text message
//drop animation init
- (id) initDropAlertWithTitle:(NSString*) title andText:(NSString*) text andCancelButton: BOOL)hasCancelButton forAlertType:(AlertType) type;
- (id) initDropAlertWithTitle:(NSString*) title andText:(NSString*) text andCancelButton:(BOOL)hasCancelButton forAlertType:(AlertType) type andColor:(UIColor*) color;
//fade in animation init
- (id) initFadeAlertWithTitle:(NSString*) title andText:(NSString*) text andCancelButton:(BOOL)hasCancelButton forAlertType:(AlertType) type;
- (id) initFadeAlertWithTitle:(NSString*) title andText:(NSString*) text andCancelButton:(BOOL)hasCancelButton forAlertType:(AlertType) type andColor:(UIColor*) color;
//set corner radius or not on the alertView
- (void) setCornerRadius:(float)cornerRadius;
//show the alertview!
- (void) show;
//dismiss it !
- (void) dismissAlertView;
支持完成块
alert.completionBlock = ^void (AMSmoothAlertView *alertObj, UIButton *button) {
if(button == alertObj.defaultButton) {
NSLog(@"Default");
} else {
NSLog(@"Others");
}
};
您可以编辑标题和文本字体、圆形图标、颜色和“确定”按钮(即将推出多按钮功能)。
//title font customization
[alert setTitleFont:[UIFont fontWithName:@"Verdana" size:25.0f]];
//text message font customization
[alert setTextFont:[UIFont fontWithName:@"Futura-Medium" size:13.0f]];
//icon customization
[alert.logoView setImage:[UIImage imageNamed:@"checkMark.png"]];
目前有三种类型的弹出视图
typedef enum AlertType : NSInteger AlertType;
enum AlertType : NSInteger {
AlertSuccess,
AlertFailure,
AlertInfo
};
也请查看我的其他控制器 AMLoginViewController
Antoine