iOS 简单提示view
2015-08-13 18:05
375 查看
+(void)showMessage:(NSString *)message
{
UIWindow * window = [UIApplication sharedApplication].keyWindow;
UIView *showview = [[UIView alloc]init];
showview.backgroundColor = [UIColor blackColor];
showview.frame = CGRectMake(1, 1, 1, 1);
showview.alpha = 1.0f;
showview.layer.cornerRadius = 5.0f;
showview.layer.masksToBounds = YES;
[window addSubview:showview];
UILabel *label = [[UILabel alloc]init];
CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)];
label.frame = CGRectMake(10, 5, LabelSize.width, LabelSize.height);
label.text = message;
label.textColor = [UIColor whiteColor];
label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:13];
[showview addSubview:label];
showview.frame = CGRectMake((ScreenWidth - LabelSize.width - 20)/2, 200, LabelSize.width+20, LabelSize.height+10);
[UIView animateWithDuration:2.5 animations:^{
showview.alpha = 0;
} completion:^(BOOL finished) {
[showview removeFromSuperview];
}];
}
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width//获取屏幕宽度
{
UIWindow * window = [UIApplication sharedApplication].keyWindow;
UIView *showview = [[UIView alloc]init];
showview.backgroundColor = [UIColor blackColor];
showview.frame = CGRectMake(1, 1, 1, 1);
showview.alpha = 1.0f;
showview.layer.cornerRadius = 5.0f;
showview.layer.masksToBounds = YES;
[window addSubview:showview];
UILabel *label = [[UILabel alloc]init];
CGSize LabelSize = [message sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(290, 9000)];
label.frame = CGRectMake(10, 5, LabelSize.width, LabelSize.height);
label.text = message;
label.textColor = [UIColor whiteColor];
label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:13];
[showview addSubview:label];
showview.frame = CGRectMake((ScreenWidth - LabelSize.width - 20)/2, 200, LabelSize.width+20, LabelSize.height+10);
[UIView animateWithDuration:2.5 animations:^{
showview.alpha = 0;
} completion:^(BOOL finished) {
[showview removeFromSuperview];
}];
}
#define ScreenWidth [[UIScreen mainScreen] bounds].size.width//获取屏幕宽度
相关文章推荐
- iOS中的内存管理精讲
- iOS开发 - 加载三方字体库
- iOS 短信分享 邮件分享
- IOS点击空白处隐藏键盘的几种方法
- iOS开发各类技术链接
- 【高德API】如何利用MapKit开发全英文检索的iOS地图
- iOS Xcode 解决每次版本更新后插件都不好用的问题
- ios中json解析出现的null问题
- iOS Provisioning Profile(Certificate)与Code Signing详解
- iOS设计模式汇总
- iphone5 ios7.1 上下有黑边 解决方案
- 27个提升效率的iOS开源库推荐
- IOS BLE4.0蓝牙和外设连接和收发数据的流程
- iOS每日一记之---------改变Btn点击时的背景颜色
- C#获取电脑硬件信息(CPU ID、主板ID、硬盘ID、BIOS编
- ios afnetworking 错误解决
- 我的iOS高效编程秘诀—坚持编程习惯
- iOS小白进阶之旅(一)
- iOS 开发中农历与公历的转换,星座计算。
- nagios服务的搭建