通过xib创建一个自界说弹窗:
该弹窗可以自界说view的配景,颜色,字体的巨细,颜色调整
方便编写,调用简单:
LoginAlertTableView.h
LoginAlertTableView.m
import "LoginAlertTableView.h"
@interface LoginAlertTableView()
@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UIView *contetView;
@property (nonatomic, copy) void(^Block)(void);
@end
@implementation LoginAlertTableView
static LoginAlertTableView *manager = nil;
+(instancetype)shareManager
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
manager= [[[NSBundle mainBundle] loadNibNamed"LoginAlertTableView" owner:self options:nil] lastObject];
});
return manager;
}
//展示
-(void)show
{
self.hidden = NO;
CGAffineTransform transform = CGAffineTransformScale(CGAffineTransformIdentity,1.0,1.0);
self.contetView.transform = CGAffineTransformScale(CGAffineTransformIdentity,0.2,0.2);
self.contetView.alpha = 0;
self.frame=CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
[[UIApplication sharedApplication].keyWindow addSubview:self];
[UIView animateWithDuration:0.3 delay:0.1 usingSpringWithDamping:0.5 initialSpringVelocity:10 options:UIViewAnimationOptionCurveLinear animations:^{
self.contetView.transform = transform;
self.contetView.alpha = 1;
self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.3f];
} completion:^(BOOL finished) {
[self performSelectorselector(dismissAlert withObject:self afterDelay:1.0];
}];
}
//潜伏
-(void)dismissAlertUIView *)view{
[self dismiss];
if (self.Block) {
self.Block();
}
}
//潜伏
-(void)dismiss
{
[UIView animateWithDuration:0.3 animations:^{
self.contetView.transform=CGAffineTransformMakeScale(0.02, 0.02);
} completion:^(BOOL finished) {
[self removeFromSuperview];
}];
}
+(LoginAlertTableView *)titleNSString *)title showvoid(^)(void))block{
LoginAlertTableView *view = [LoginAlertTableView shareManager];
view.titleLabel.text = title;
view.Block = block;
[view show];
return view;
}
- (IBAction)cancelBtnClickid)sender {
[self dismiss];
}
@end
|