UIWindow
来源:互联网 发布:mac给ios手机装 编辑:程序博客网 时间:2024/06/05 10:01
/UIWindow : UIView
@interface ViewController ()
@property(strong,nonatomic)UIWindow *window;
@property(strong,nonatomic)UIButton *buttonShow;
@property(strong,nonatomic)UIButton *buttonHide;
@end
//window应用场景:不基于任何父视图,独立显示,window上可以贴子视图,一般用于制作悬浮窗
//你自定义的window不要在系统创建window之前
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
self.buttonShow = [UIButtonbuttonWithType:UIButtonTypeCustom];
self.buttonShow.frame =CGRectMake(10,20, 100,30);
self.buttonShow.backgroundColor = [UIColorredColor];
//Button设置文本只能通过调用方法
[self.buttonShowsetTitle:@"显示悬浮窗"forState:UIControlStateNormal];
//设置按钮字体大写
self.buttonShow.titleLabel.font = [UIFont systemFontOfSize:15];
[self.buttonShowaddTarget:selfaction:@selector(tapButtonShow)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:self.buttonShow];
self.buttonHide = [UIButtonbuttonWithType:UIButtonTypeCustom];
self.buttonHide.frame =CGRectMake(150,20, 100,30);
self.buttonHide.backgroundColor = [UIColorredColor];
//Button设置文本只能通过调用方法
[self.buttonHidesetTitle:@"隐藏悬浮窗"forState:UIControlStateNormal];
//设置按钮字体大写
self.buttonHide.titleLabel.font = [UIFont systemFontOfSize:15];
[self.buttonHideaddTarget:selfaction:@selector(tapButtonHide)forControlEvents:UIControlEventTouchUpInside];
[self.viewaddSubview:self.buttonHide];
self.window =[[UIWindowalloc]initWithFrame:CGRectMake(250,250, 80,80)];
self.window.backgroundColor = [UIColorlightGrayColor];
//设置window的显示层级,UIWindowLevelAlert显示在最前面,
self.window.windowLevel =UIWindowLevelAlert;
self.window.layer.cornerRadius = 40;
//自定义的window需要在系统的window之后
// [self.window makeKeyAndVisible];
//练习:window上可以贴子视图
}
- (void)tapButtonShow
{
//显示window
NSLog(@"hidden = %d",self.window.hidden);
//makeKeyAndVisible显示window,优先级比hidden高
[self.windowmakeKeyAndVisible];
}
- (void)tapButtonHide
{
self.window.hidden =YES;
}
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWINDOW
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- UIWindow
- 策略模式(Strategy)
- C++四种类型转换
- NSOperation封装- 多任务下载
- Map、Set、List、Queue、Stack的特点与用法1
- 将内容追加到文件尾部-采用字符流的形式,将abc.txt中的内容更换为 好好学习,天天向上!
- UIWindow
- 磁盘 分区
- 复制一个文件
- 白话经典算法系列之十六 “基数排序”之数组中缺失的数字
- 微信移动应用接入开发, Android 授权微信登录获取openid,unionid等,score参数错误或者没有scope权限
- Map、Set、List、Queue、Stack的特点与用法2
- 【程序员养生】:养护肾脏
- poj1328(贪心)
- ThreadPoolExecutor JDK线程池