iOS - 自界说弹窗

手机软件开发 2024-10-3 12:33:40 61 0 来自 中国
通过xib创建一个自界说弹窗:
该弹窗可以自界说view的配景,颜色,字体的巨细,颜色调整
方便编写,调用简单:
1.png 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
您需要登录后才可以回帖 登录 | 立即注册

Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )

GMT+8, 2024-11-21 20:31, Processed in 0.241245 second(s), 35 queries.© 2003-2025 cbk Team.

快速回复 返回顶部 返回列表