import "AppDelegate.h"
// 宏定義顏色
define COLORRGB(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
// 創(chuàng)建一個UI view對象
UIView *view = [[UIView alloc]init];
UIView *view1 = [[UIView alloc]init];
// 設(shè)置它的frame
view.frame = CGRectMake(0, 100,100 , 100);
view1.frame = CGRectMake(0, 100, 100, 100);
// 設(shè)置背景顏色
// 宏定義顏色的使用 view.backgroundColor = COLORRGB(100, 100, 100, 1);
view.backgroundColor = [UIColor blueColor];
view1.backgroundColor = [UIColor redColor];
// 呈現(xiàn)view對象
[self.window addSubview:view];
[self.window addSubview:view1];
// [self.window bringSubviewToFront:<#(nonnull UIView *)#>]
[self.window exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
// UIView *view2 = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 150)];
// view2.backgroundColor = [UIColor blueColor];
// [self.window addSubview:view2];
// // 得到view2的父view
// id supView = view2.superview;
// NSLog(@"%p\n%p",supView,self.window);
//
// // 判斷對象類型
// BOOL result = [supView isKindOfClass:[UIWindow class]];
// NSLog(@"result = %d",result);
//
// // 得到view2的各個參數(shù)
// float x = view2.frame.origin.x;
// float y = view2.frame.origin.y;
// float width = view2.frame.size.width;
// float height = view2.frame.size.height;
//
// NSLog(@"view2Frame--%@",NSStringFromCGRect(view2.frame));
//
// NSLog(@"view2Bounds--%@",NSStringFromCGRect(view2.bounds));
//
// NSLog(@"view2FrameByPoint--%@",NSStringFromCGPoint(view2.frame.origin));
//
// NSLog(@"view2FrameBySize--%@",NSStringFromCGSize(view2.frame.size));
//
// NSLog(@"x = %.1f,y = %.1f,width = %.1f,height = %.1f",x,y,width,height);
// // bounds是本身的原點耿焊,只會影響它的子view
// view2.bounds = CGRectMake(100, 100, 100, 150);
//
//// [view2 setBounds:CGRectMake(50, 50, 100, 100)];
//
// // 以view2作為父view,新建一個view0
// UIView *view0 =[[UIView alloc]initWithFrame:CGRectMake( 50, 50, 50, 50)];
// view0.backgroundColor = [UIColor yellowColor];
// [view2 addSubview:view0];
// // 打印view2的center
// NSLog(@"view2Center--%@",NSStringFromCGPoint(view2.center));
// // 更改center
// // { center的(x,y)本質(zhì)上就是父view的frame(x,y),如果改變center,frame(x,y)也會隨之改變}
// view2.center = CGPointMake(100, 200);
//
// // 把view2的center設(shè)置成window的center
// view2.center = CGPointMake(self.window.frame.size.width/2, self.window.frame.size.height/2);
//
// // 把view2隱藏
// // view2.hidden = YES;
//
// // 設(shè)置透明度,取值范圍(0,1) 0:表示透明 恳不; 1:表示不透明
// view2.alpha = 1;
//
// // 得到它的所有子view (如果需要得到子視圖中的某一類視圖,需要遍歷的時候配合iskindofclass來使用)
// // view2.subviews
//
// // 給view設(shè)置標(biāo)記(tag) 建議從1000以后設(shè)置
// view2.tag = 100;
//
// // 從父視圖上通過tag值得到相應(yīng)的子視圖
// UIView *tagView = [self.window viewWithTag:100];
// 創(chuàng)建 UILable (標(biāo)簽)
UILabel *lable = [[UILabel alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
// lable呈現(xiàn)文字
lable.text = @"我是四班最帥的!我是四班最帥的!我是四班最帥的!我是四班最帥的!";
// 設(shè)置字體顏色
lable.textColor = [UIColor whiteColor];
// 設(shè)置字體大小
[lable setFont:[UIFont systemFontOfSize:10]];
// 顯示不完全時,省略號的位置
lable.lineBreakMode = NSLineBreakByTruncatingMiddle;
// 設(shè)置文字顯示位置 (枚舉類型:0居左墅诡,1居中,2居右)
lable.textAlignment = NSTextAlignmentCenter;
// 設(shè)置行數(shù)(默認的為1行桐智,0表示自動換行)
[lable setNumberOfLines:1];
// 設(shè)置字體陰影顏色
lable.shadowColor = [UIColor yellowColor];
// 設(shè)置陰影偏移量
lable.shadowOffset = CGSizeMake(3, 3);
// 設(shè)置lable的背景顏色
lable.backgroundColor = [UIColor blueColor];
[self.window addSubview:lable];
[self.window setRootViewController:[[UIViewController alloc]init]];
return YES;
}