-
//通過tug值,得到對(duì)應(yīng)的子視圖 UIView *subView = [view1 viewWithTag:3]; subView.backgroundColor = [UIColor orangeColor]; /*層級(jí) 1.同一個(gè)父視圖中 先加入的view會(huì)被蓋在下面 2.子視圖層級(jí)跟隨父視圖進(jìn)行層級(jí)遮擋,如父視圖層級(jí)低于其他同級(jí)視圖則父視圖的子視圖也會(huì)被遮擋,但是子視圖和其他視圖中的子視圖是沒有關(guān)系的 3.交換兩個(gè)層的視圖時(shí),必須填寫正確的層數(shù) 0開始遞增 4.層交換后,對(duì)應(yīng)的子視圖數(shù)組下標(biāo)也會(huì)改變*/ //交換兩個(gè)層的視圖 [view1 exchangeSubviewAtIndex:0 withSubviewAtIndex:1]; //插入一個(gè)視圖到指定層 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]; //將一個(gè)VIEW放入:最頂層 //[view1 bringSubviewToFront:view3]; //最底層 [view1 sendSubviewToBack:view3];查看全部
-
//父視圖 UIView *superView = view1.superview; superView.backgroundColor =[UIColor greenColor]; //坐標(biāo)是根據(jù)父視圖的位置來(lái)設(shè)置的不會(huì)夸層 UIView *view2 = [[UIView alloc]init]; view2.frame = CGRectMake(10, 20, 300, 30); view2.backgroundColor =[UIColor blackColor]; //唯一標(biāo)識(shí) 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值,得到對(duì)應(yīng)的子視圖 UIView *subView = [view1 viewWithTag:3]; subView.backgroundColor = [UIColor orangeColor];查看全部
-
//location size狀態(tài)欄高20,設(shè)置frame時(shí)需要讓出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狀態(tài)欄高20,設(shè)置frame時(shí)需要讓出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 */ //現(xiàn)實(shí)當(dāng)前設(shè)備的屏幕尺寸 NSLog(@"w:%f h:%f",[[UIScreen mainScreen] bounds].size.width,[[UIScreen mainScreen] bounds].size.height); }查看全部
-
設(shè)置頻幕寬高查看全部
-
124查看全部
-
手機(jī),單界面查看全部
-
狀態(tài)欄高度20像素查看全部
-
雖然是單窗口,但是可以有多個(gè)window查看全部
-
手機(jī)是單窗口應(yīng)用查看全部
-
ui視圖查看全部
-
將所有的序列圖放入數(shù)組中并且實(shí)例化查看全部
-
加載圖片的方式查看全部
-
各型號(hào)圖片尺寸查看全部
-
UI界面設(shè)計(jì)基礎(chǔ)介紹查看全部
舉報(bào)
0/150
提交
取消