iOS开发中需要弹出提示框来提示用户一些信息,但是MBProgressHud的显示可能会导致文字显示不全,这个时候就需要自定义一个弹出框来显示自己需要的文字.
@property (nonatomic,strong) UIView * alertView;
@property (nonatomic,strong) UILabel * label;
#pragma mark -自定义alertview
-(void)updataWindows {
self.alertView = [[UIViewalloc]initWithFrame:CGRectMake(40,self.view.frame.size.height/2 -40, self.view.frame.size.width -80, 80)];
self.alertView.backgroundColor = [UIColorblackColor];
self.alertView.layer.masksToBounds = YES;
self.alertView.layer.cornerRadius = 8.0f;
self.label = [[UILabelalloc]initWithFrame:CGRectMake(0,0, self.alertView.bounds.size.width,80)];
self.label.numberOfLines =3;
self.label.text = @" 您的信息已经重新提交,我们正在在加紧审核,请稍侯 ";
self.label.textColor = [UIColorwhiteColor];
self.label.textAlignment = NSTextAlignmentCenter;
[self.alertViewaddSubview:self.label];
[self.viewaddSubview:_alertView];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
//2秒以后移除view
[self.alertViewremoveFromSuperview];
});
}
如图