很多時(shí)候,iOS開發(fā)中需要彈出提示框來提示用戶一些信息,但是MBProgressHud的顯示可能會(huì)導(dǎo)致文字顯示不全,這個(gè)時(shí)候就需要自定義一個(gè)彈出框來顯示自己需要的文字.
-(void)updataWindows {
windows = [UIApplication sharedApplication].keyWindow;
view = [[UIView alloc]initWithFrame:CGRectMake(40, SCREEN_HEIGHT/2 - 40, SCREEN_WIDTH - 80, 80)];
view.backgroundColor = [UIColor blackColor];
view.layer.masksToBounds = YES;
view.layer.cornerRadius = 8.0f;
label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, view.bounds.size.width, 80)];
label.numberOfLines = 3;
label.text = @" 您的信息已經(jīng)重新提交,我們正在在加緊審核,請(qǐng)稍侯 ";
label.textColor = [UIColor whiteColor];
label.textAlignment = NSTextAlignmentCenter;
[windows addSubview:view];
[view addSubview:label];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)),dispatch_get_main_queue(), ^{
//2秒以后移除view
[view removeFromSuperview];
});
}
這樣就可以做出和MBProgressHud相似的效果了.