日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

UIView

發(fā)布時間:2024/10/12 编程问答 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 UIView 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

UIView

cmd + 1模擬器比例100%

cmd + 2模擬器比例75%

cmd + 3模擬器比例50%

cmd + 4模擬器比例33%

cmd + 5模擬器比例25%

cmd + shift + h 點擊Home

cmd + shift + k 模擬器連接物理鍵盤

cmd + k 隱藏或者顯示虛擬器上的鍵盤

cmd + shift + hh 顯示所有打開的應(yīng)用程序

cmd + l 鎖屏

刪除應(yīng)用: 長按應(yīng)用, 點擊x

cmd + s 截屏

程序的入口是main函數(shù)

int main(int argc, char * argv[]) {@autoreleasepool {NSLog(@"程序的入口main函數(shù)");//指定程序的代理為AppDelegate//所有和程序相關(guān)的操作都是由AppDelegate來處理return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));} }

Extension, 延展, 私有方法的聲明和在類內(nèi)部使用的實例變量

@interface AppDelegate ()@end @implementation AppDelegate -(void)dealloc {[_window release];[super dealloc]; }

程序已經(jīng)完成加載

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
} - (void)applicationWillResignActive:(UIApplication *)application {NSLog(@"程序?qū)⒁N激活");
} - (void)applicationDidEnterBackground:(UIApplication *)application {NSLog(@"程序已經(jīng)進入后臺"); } - (void)applicationWillEnterForeground:(UIApplication *)application {NSLog(@"程序?qū)⒁M入前臺"); } - (void)applicationDidBecomeActive:(UIApplication *)application {NSLog(@"程序已經(jīng)激活"); } - (void)applicationWillTerminate:(UIApplication *)application {NSLog(@"程序?qū)⒁K止"); }

?UI: User Interface, 用戶界面

?UIWindow, 窗口類, 所有的控件必須放到window上才能顯示, 一個iOS應(yīng)用至少要有一個窗口, 繼承于UIView

?iOS手機中的坐標系, 不同于數(shù)學(xué)中的笛卡爾坐標系, 原點在左上角, x: 向右越來越大, y: 向下越來越大

?與坐標系相關(guān)的數(shù)據(jù)類型

? CGPoint, 結(jié)構(gòu)體, 用于存放一個點的坐標

CGPoint point = CGPointMake(10, 100);NSLog(@"%.lf, %.lf", point.x, point.y);NSLog(@"%@", NSStringFromCGPoint(point));

?CGSize, 結(jié)構(gòu)體, 用于存放矩形的寬和高

CGSize size = CGSizeMake(150, 200);NSLog(@"%.lf %.lf", size.width, size.height);NSLog(@"%@", NSStringFromCGSize(size));

CGRect, 結(jié)構(gòu)體, 用于存放矩形的位置和大小

CGRect rect = CGRectMake(10, 100, 150, 200);NSLog(@"%.lf %.lf %.lf %.lf", rect.origin.x, rect.origin.y, rect.size.width, rect.size.height);NSLog(@"%@", NSStringFromCGRect(rect));

?[UIScreen mainScreen] bounds], 主屏幕的大小

?[UIScreen mainScreen], 獲取到主屏幕

?UIScreen, 屏幕類

?? NSLog(@"%@", NSStringFromCGRect([[UIScreen mainScreen] bounds]));?

?屏幕大小(單位:pt, point)

? ? 1, 3g, 3gs, 4, 4s: [320 * 480]

? ? 5, 5s, 5c: [320 * 568]

? ? 6, 6s: [375 * 667]

? ? 6 Plus, 6s Plus: [414 * 736]

?創(chuàng)建一個和屏幕大小一樣的window對象

?? self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];?

UIColor, 顏色類, 繼承于NSObject, 用于展示一種顏色

RGBA, 取值范圍[0, 1]

? UIColor *color = [UIColor colorWithRed:0.656 green:1.000 blue:0.838 alpha:1.000];??

設(shè)置背景顏色

? self.window.backgroundColor = [UIColor purpleColor];?

讓當(dāng)前窗口成為主窗口, 并顯示

?[self.window makeKeyAndVisible];?

? ARC->MRC

? ? 1.gar

? ? 2.strong->retain

? ? 3.重寫dealloc方法

? ? 4.window, autorelease

?UIView, 繼承于UIResponder, 一個矩形區(qū)域, 所有的控件都是繼承于UIView, 用戶在手機上能夠看到的都是UIViewUIView的子類

?創(chuàng)建一個視圖的步驟? ?

1.創(chuàng)建視圖, 并設(shè)定位置和大小UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(20, 30, 100, 200)];//2.設(shè)置視圖屬性//顏色aView.backgroundColor = [UIColor purpleColor];//是否隱藏aView.hidden = YES;//不透明度aView.alpha = 0.6;//3.添加到window上 [self.window addSubview:aView];//4.釋放視圖[aView release]; UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];redView.backgroundColor = [UIColor redColor];redView.hidden = YES;redView.alpha = 0.7;[self.window addSubview:redView];[redView release];UIView *blueView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];blueView.backgroundColor = [UIColor blueColor];blueView.hidden = YES;blueView.alpha = 0.7;[self.window addSubview:blueView];[blueView release];UIView *greenView = [[UIView alloc] initWithFrame:CGRectMake(150, 150, 100, 100)];greenView.backgroundColor = [UIColor greenColor];greenView.hidden = YES;greenView.alpha = 0.7;[self.window addSubview:greenView];[greenView release];

隨機位置, 隨機顏色, 創(chuàng)建視圖

UIColor *randomColor = [UIColor colorWithRed:arc4random() % 256 / 255. green:arc4random() % 256 / 255. blue:arc4random() % 256 / 255. alpha:arc4random() % 256 / 255.]; for (NSInteger i = 0; i < 1888; i++) {UIView *view = [[UIView alloc] initWithFrame:CGRectMake(arc4random() % (375 - 10 + 1) / 1. , arc4random() % (667 - 10 + 1) / 1., 10, 10)];view.backgroundColor = [UIColor colorWithRed:arc4random() % 256 / 255. green:arc4random() % 256 / 255. blue:arc4random() % 256 / 255. alpha:1];[self.window addSubview:view];[view release];}

?視圖的層級關(guān)系

? ? 1.越晚添加的視圖, 顯示在最前面

? ? 2.一個視圖只能有一個父視圖, 但是可以有多個子視圖

? ? 3.一個視圖位置, 是相對于它的父類視圖坐標系計算的

UIView *redView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 300, 300)];redView.backgroundColor = [UIColor redColor];redView.hidden = NO;redView.alpha = 0.8;[self.window addSubview:redView];[redView release];UIView *blueView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];blueView.backgroundColor = [UIColor blueColor];blueView.hidden = NO;blueView.alpha = 0.7;//超出父視圖部分是否切除, 默認NOblueView.clipsToBounds = YES;[redView addSubview:blueView];[blueView release];UIView *greenView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 100, 100)];greenView.backgroundColor = [UIColor greenColor];greenView.hidden = NO;greenView.alpha = 0.7;[blueView addSubview:greenView];[greenView release];

//父視圖NSLog(@"%@", redView.superview);//子視圖NSLog(@"%@", redView.subviews);NSLog(@"%@", self.window.subviews);

center, 基于父視圖坐標系, 視圖中心點在父視圖坐標系中的位置

NSLog(@"%@", NSStringFromCGPoint(redView.center));NSLog(@"%@", NSStringFromCGPoint(blueView.center));

frame, 基于父視圖坐標系, 視圖在父視圖坐標系中的位置和大小

NSLog(@"%@", NSStringFromCGRect(redView.frame));NSLog(@"%@", NSStringFromCGRect(blueView.frame));

bounds, 基于自身坐標系, 視圖在自身坐標系中的位置和大小, 默認值:{0, 0, w, h}

NSLog(@"%@", NSStringFromCGRect(redView.bounds));redView.bounds = CGRectMake(100, 100, 300, 300);

UIView屬性

? ? 1.backgroundColor(默認透明色)

? ? 2.hidden

? ? 3.alpha

? ? 4.clipsToBounds

? ? 5.superView

? ? 6.subViews

? ? 7.center

? ? 8.frame

? ? 9.bounds

?

?

轉(zhuǎn)載于:https://www.cnblogs.com/OrangesChen/p/4883613.html

與50位技術(shù)專家面對面20年技術(shù)見證,附贈技術(shù)全景圖

總結(jié)

以上是生活随笔為你收集整理的UIView的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。