关于提示框的小例子
来源:互联网 发布:aotudesk是什么软件 编辑:程序博客网 时间:2024/05/22 00:38
最经写了一个关于提示框弹出的小例子,用于当某项任务完成时,提示相关的消息等等。
showeview.h
#import <UIKit/UIKit.h>
@interface showeview : UIView
+ (id) sharedInstance;
-(void)showMessage:(NSString *)message;
@end
#import "showeview.h"
//获取屏幕宽度、高度
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
//获取设备大小
@implementation showeview
//声明一个全局唯一的静态对象,也是AccountManager类型
static showeview * _sharedInstance;
//方法实现
+ (id) sharedInstance {
@synchronized ([showeview class]) {
if (_sharedInstance == nil) {
_sharedInstance = [[showeview alloc] init];
}
}
return _sharedInstance;
}
-(void)showMessage:(NSString *)message
{
UIWindow * window = [UIApplication sharedApplication].keyWindow;
UIView *showview = [[UIView alloc]init];
showview.backgroundColor = [UIColor blackColor];
// showview.frame = CGRectMake(100, 500, 100, 100);
showview.alpha = 0.6f;
//设置圆角
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 redColor];
label.textAlignment = 1;
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont boldSystemFontOfSize:15];
[showview addSubview:label];
showview.frame = CGRectMake((SCREEN_WIDTH-(LabelSize.width+20))/2,(SCREEN_HEIGHT-(LabelSize.height+10))/2, LabelSize.width+20, LabelSize.height+10);
[UIView animateWithDuration:1.5 animations:^{
showview.alpha = 0;
} completion:^(BOOL finished) {
[showview removeFromSuperview];
}];
}
@end
- 关于提示框的小例子
- 关于类的小例子
- 关于autocomplete的小例子
- 关于List 的小例子
- 关于json的小例子
- 安卓关于输入提示后缀选择的注册邮箱项小例子
- 关于fcntl()的小提示
- 关于 addSubView 的小提示
- 一个关于反射的小例子
- jfreechar关于坐标轴的几个小例子
- 关于Tree的一个小例子
- 关于String操作的一个小例子
- 关于JNI技术的一个小例子
- 关于私有继承的一个小例子
- 关于static初始化的小例子
- 关于ExpandableListView的一个小例子
- 关于重力感应的一个小例子
- 关于递归问题的一些小例子
- Akka简介
- 第十一节 进程间通信
- Leetcode45:Intersection of Two Linked Lists
- php框架优秀框架laravel学习(-)
- sqlldr使用中遇到的字符集问题
- 关于提示框的小例子
- Windows下cscope:can't find the source file
- java基础--开发工具
- SHUTDOWN_MSG: Shutting down NameNode at java.net.UnknownHostException
- Tomcat --> Cannot create a server using the selected type
- 一个牛x的mock框架--Powermock
- [CAQ2]使用getRunningServices判断服务是否运行不好用
- 学堂在线C++进阶 编程题 10-2
- Razor模板引擎