UIView及其子类
来源:互联网 发布:数据采集系统应用领域 编辑:程序博客网 时间:2024/04/23 16:33
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. //创建window self.window = [[UIWindow alloc ]init]; //让window和屏幕的宽高一样,位置也一样 _window.frame =[ UIScreen mainScreen].bounds;//bounds =(0,0,屏幕宽,屏幕高) _window.backgroundColor = [UIColor yellowColor]; //上面两步相当于 //self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds]; //显示屏幕 [_window makeKeyAndVisible]; //创建BlueView试图 //开辟空间并初始化 UIView * blueView = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)]; //对视图进行设置 blueView.backgroundColor = [UIColor blueColor]; //将视图添加到window来显示 [_window addSubview:blueView]; //释放视图对象 UIView * redView = [[UIView alloc]initWithFrame:CGRectMake(100, 300, 100, 100)]; //对视图进行设置 redView.backgroundColor = [UIColor redColor]; //将试图添加到window来显示 [_window addSubview:redView]; //释放视图对象 UIView * blackView = [[UIView alloc]initWithFrame:CGRectMake(100, 200, 100, 100)]; blackView.backgroundColor = [ UIColor blackColor]; [_window addSubview:blackView]; //参照blueview(父视图)左上角的起点位置, UIView * orangeView =[[UIView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)]; orangeView.backgroundColor = [UIColor orangeColor]; [blueView addSubview:orangeView]; //修改中心点位置 //blackView.center = CGPointMake(200, 300); CGPoint tempCenter = blackView.center; tempCenter.x = 200; tempCenter.y = 350; blackView.center = tempCenter; [_window release]; [blueView release]; [redView release]; [blackView release ]; [orangeView release];#pragma mark----frame,center,bounds //frame:可以改变视图的大小和位置,相对于父视图 //center:只能改变视图的位置 //bounds:能改变视图的大小,但是中心点不会改变,相对于自身。但是它会影响这个视图上所有子视图的布局(位置)。#pragma mark-----添加视图 UIView * grayView =[[UIView alloc]initWithFrame:CGRectMake(50, 50, 100, 100)]; grayView.backgroundColor =[UIColor grayColor]; [_window insertSubview:grayView atIndex:0]; [grayView release]; //将grayview移到最前面(最上面) [_window bringSubviewToFront:grayView]; //将redView从父视图上移除 //[redView removeFromSuperview]; //UIView的相关属性 //redView.hidden = YES;//设置视图是否隐藏 redView.alpha = 0.5;//设置透明度,默认1.0 ; NSLog(@"%@",redView .superview);//获取父视图 NSLog(@"%@",redView.subviews);//获取某视图上的所有子视图 grayView.tag = 100; UIView * v =[_window viewWithTag:100]; NSLog(@"%@",v);#pragma mark----UILable UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(100, 400, 200, 60)]; //设置文本内容(显示的内容) label.text = @"Hello Baby! Can I make L with you!"; //背景颜色 label.backgroundColor = [UIColor cyanColor]; //文本字体 label.font = [UIFont fontWithName:@"Times New Roman" size:14]; NSLog(@"%@",[UIFont familyNames]); //文本颜色 label.textColor = [UIColor redColor]; //设置对齐方式 label.textAlignment= 0 ; //设置换行模式 label.lineBreakMode= NSLineBreakByWordWrapping ; //设置行数 label.numberOfLines = 3; //设置文本阴影 label.shadowColor =[ UIColor blackColor]; //设置阴影的偏移量 label.shadowOffset = CGSizeMake(20,20); [_window addSubview:label]; [label release];
0 0
- UIView及其子类
- UIView及其子类
- UIView及其子类
- UIView及其子类
- UIView及其子类 切圆角
- UI第一节:UIView及其子类
- 第一讲 UIView及其子类
- UI编程:UIView及其子类
- UI基础-UIView及其子类
- 为UIView及其子类添加圆角边
- iOS UIView及其子类的重绘
- 第⼀讲:UIView及其⼦子类
- UI编程-UIView及其⼦子类
- UI课程01 UIView及其子类
- 随意细解:UI -- UIView及其子类
- 为UIView及其子类添加圆角边框
- 为UIView及其子类添加圆角边框
- UIView及其子类围绕任意点旋转的方法
- AsyncTask基本原理
- 回文词
- 堆排序算法
- 程序员必读书单
- 开始iOS 7中自动布局教程(一)
- UIView及其子类
- C++自增自减重载
- C++builder的文件读写操作总结(2)
- C++builder的文件读写操作总结(1)
- iOS打IPA包
- Qt汉字得到汉字拼音首字母
- 黑马程序员07 IO流
- 快学Scala习题解答—第十一章 操作符
- tiny_mce