弹出一个对话框

1.代码设置

{

//1.创建一个label

UILabel*lblMsg=[[UILabelalloc]init];

//1.1设置文字

lblMsg.text=@"正在下载中...";

//1.2设置背景色

lblMsg.backgroundColor=[UIColorblackColor];

//1.3设置文字颜色

lblMsg.textColor=[UIColorredColor];

//1.4设置frame

CGFloatmsgW=200;

CGFloatmsgH=40;

CGFloatmsgX=(self.view.frame.size.width-msgW)*0.5;

CGFloatmsgY=(self.view.frame.size.height-msgH)*0.5;

lblMsg.frame=CGRectMake(msgX, msgY, msgW, msgH);

//1.5修改label文字大小

//lblMsg.font=[UIFont systemFontOfSize:14];

//1.6设置文字居中显示

lblMsg.textAlignment=NSTextAlignmentCenter;

//1.7设置文字粗体

lblMsg.font=[UIFontboldSystemFontOfSize:14];

//1.8设置透明度

lblMsg.alpha=0.0;

//设置圆角

lblMsg.layer.cornerRadius=10;

lblMsg.layer.masksToBounds=YES;

//1.9通过动画方式显示label

[UIViewanimateWithDuration:1.5animations:^{

lblMsg.alpha=0.6;

}completion:^(BOOLfinished) {

if(finished) {

[UIViewanimateWithDuration:1.0delay:1.0options:UIViewAnimationOptionCurveLinearanimations:^{//匀速

lblMsg.alpha=0;

}completion:^(BOOLfinished) {

if(finished) {

[lblMsgremoveFromSuperview];

}

}];

}

}];

//2.把label加到self.view

//因为现在使用的是UITableViewController控制器,所以self.view就是UITableView,当把lblMsg加到self.view中,也就加到了UITableView中,所以滚动的时候也会随着滚动

//[self.view addSubview:lblMsg];

[[[UIApplicationsharedApplication]keyWindow]addSubview:lblMsg];

}

2.三方框架

导入MBProgressHUD

你可能感兴趣的