-
//通过tug值,得到对应的子视图 UIView *subView = [view1 viewWithTag:3]; subView.backgroundColor = [UIColor orangeColor]; /*层级 1.同一个父视图中 先加入的view会被盖在下面 2.子视图层级跟随父视图进行层级遮挡,如父视图层级低于其他同级视图则父视图的子视图也会被遮挡,但是子视图和其他视图中的子视图是没有关系的 3.交换两个层的视图时,必须填写正确的层数 0开始递增 4.层交换后,对应的子视图数组下标也会改变*/ //交换两个层的视图 [view1 exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; //插入一个视图到指定层 UIView *view5=[[UIView alloc]init]; view5.frame =CGRectMake(7, 80, 200, 200); view5.backgroundColor = [UIColor grayColor]; //[view1 insertSubview:view5 atIndex:5]; //[view1 insertSubview:view5 aboveSubview:view3]; [view1 insertSubview:view5 belowSubview:view3]; //将一个VIEW放入:最顶层 //[view1 bringSubviewToFront:view3]; //最底层 [view1 sendSubviewToBack:view3];查看全部
-
//父视图 UIView *superView = view1.superview; superView.backgroundColor =[UIColor greenColor]; //坐标是根据父视图的位置来设置的不会夸层 UIView *view2 = [[UIView alloc]init]; view2.frame = CGRectMake(10, 20, 300, 30); view2.backgroundColor =[UIColor blackColor]; //唯一标识 view2.tag =2; [view1 addSubview:view2]; // UIView *view3 = [[UIView alloc]init]; view3.frame = CGRectMake(20, 50, 100, 100); view3.backgroundColor = [UIColor purpleColor]; view3.tag =3; [view1 addSubview:view3]; //子视图subview NSArray *subViewsArray = view1.subviews; for (UIView *view in subViewsArray) { //view.backgroundColor =[UIColor whiteColor]; if (view.tag==2) { view.backgroundColor =[UIColor whiteColor]; } } //通过tug值,得到对应的子视图 UIView *subView = [view1 viewWithTag:3]; subView.backgroundColor = [UIColor orangeColor];查看全部
-
//location size状态栏高20,设置frame时需要让出20 view1.frame =CGRectMake(10, 20, 394, 706); //backgroundcolor view1.backgroundColor = [UIColor magentaColor]; //add view to 父view [self.view addSubview:view1]; /* 1.png 1@2x.png 1@3x.png 3GS 3.5inch 320*480 @1x 4/4s 3.5 320*480 @2x 640*960 5/5c/5s 320*568 @2x 640*1136 6 4.7 375*667 @2x 750*1344 6Plus 5.5 414*736 @3x 1242*2208 */ NSLog(@"w:%f h:%f",[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height); //frame NSLog(@"frame - x:%f y:%f w:%f h:%f",view1.frame.origin.x,view1.frame.origin.y,view1.frame.size.width,view1.frame.size.height); //bounds - 边框大小 x,y always zero NSLog(@"bounds - x:%f y:%f w:%f h:%f",view1.bounds.origin.x,view1.bounds.origin.y,view1.bounds.size.width,view1.bounds.size.height); //center point NSLog(@"center -x:%f y:%f ",view1.center.x,view1.center.y);查看全部
-
ViewController.m - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. //view UIView *view1 =[[UIView alloc] init]; //location size状态栏高20,设置frame时需要让出20 view1.frame =CGRectMake(100, 100, 50, 50); //backgroundcolor view1.backgroundColor = [UIColor redColor]; //add view to 父view [self.view addSubview:view1]; /* 1.png 1@2x.png 1@3x.png 3GS 3.5inch 320*480 @1x 4/4s 3.5 320*480 @2x 640*960 5/5c/5s 320*568 @2x 640*1136 6 4.7 375*667 @2x 750*1344 6Plus 5.5 414*736 @3x 1242*2208 */ //现实当前设备的屏幕尺寸 NSLog(@"w:%f h:%f",[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height); }查看全部
-
设置频幕宽高查看全部
-
124查看全部
-
手机,单界面查看全部
-
状态栏高度20像素查看全部
-
虽然是单窗口,但是可以有多个window查看全部
-
手机是单窗口应用查看全部
-
ui视图查看全部
-
将所有的序列图放入数组中并且实例化查看全部
-
加载图片的方式查看全部
-
各型号图片尺寸查看全部
-
UI界面设计基础介绍查看全部
举报
0/150
提交
取消