練習(xí)代碼day1

//應(yīng)用程序代理類

//AppDelegate中的方法都是UIApplicationDelegatez的協(xié)議方法

//應(yīng)用程序類

class AppDelegate: UIResponder, UIApplicationDelegate {

//應(yīng)用程序窗口,是 AppDelete類的屬性

var window: UIWindow?

//應(yīng)用程序加載完成觸發(fā)這個(gè)方法

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

// Override point for customization after application launch.

//想再window對(duì)象添加對(duì)象鹃锈,就在這個(gè)方法中實(shí)現(xiàn)

//屏幕類UIScreen

//UIScreen.main獲取屏幕對(duì)象

//UIScree.main.bounds

self.window=UIWindow(frame: UIScreen.main.bounds)

self.window?.backgroundColor=#colorLiteral(red: 0.5087699294, green: 0.8069495559, blue: 0.5823518634, alpha: 1)

//讓W(xué)indow成為應(yīng)用程序的主窗口笋熬,并使其可見(jiàn)

self.window?.makeKeyAndVisible()

//給window設(shè)置跟試圖控制器(現(xiàn)在制作了解)

self.window?.rootViewController=UIViewController()

//一般應(yīng)用程序只有一個(gè)window對(duì)象

return true

}

//應(yīng)用程序?qū)⒁∠钴S狀態(tài)是觸發(fā)

func applicationWillResignActive(_ application: UIApplication) {

// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.

// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.

}

//已經(jīng)進(jìn)入后臺(tái)是觸發(fā)

func applicationDidEnterBackground(_ application: UIApplication) {

// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.

// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.

}

//將要進(jìn)入前臺(tái)時(shí)觸發(fā)

func applicationWillEnterForeground(_ application: UIApplication) {

// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.

}

//應(yīng)用程序已經(jīng)變得活躍時(shí)觸發(fā)

func applicationDidBecomeActive(_ application: UIApplication) {

// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.

}

//將要結(jié)束觸發(fā)

func applicationWillTerminate(_ application: UIApplication) {

// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.

}

}

何敏? 14:54:55

class AppDelegate: UIResponder, UIApplicationDelegate {

//應(yīng)用程序窗口,是 AppDelete類的屬性

var window: UIWindow?

//應(yīng)用程序加載完成觸發(fā)這個(gè)方法

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

// Override point for customization after application launch.

//想再window對(duì)象添加對(duì)象点楼,就在這個(gè)方法中實(shí)現(xiàn)

//屏幕類UIScreen

//UIScreen.main獲取屏幕對(duì)象

//UIScree.main.bounds

self.window=UIWindow(frame: UIScreen.main.bounds)

self.window?.backgroundColor=#colorLiteral(red: 0.5087699294, green: 0.8069495559, blue: 0.5823518634, alpha: 1)

//讓W(xué)indow成為應(yīng)用程序的主窗口,并使其可見(jiàn)

self.window?.makeKeyAndVisible()

//給window設(shè)置跟試圖控制器(現(xiàn)在制作了解)

self.window?.rootViewController=UIViewController()

//一般應(yīng)用程序只有一個(gè)window對(duì)象

//UiView 創(chuàng)建方式

/*

let redView=UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))

redView.backgroundColor=#colorLiteral(red: 1, green: 0.3980397582, blue: 0.7863847613, alpha: 1)

//向window添加一個(gè)子視圖

self.window?.addSubview(redView)

//獲取屏幕的寬

let screenWidth = UIScreen.main.bounds.size.width

//獲取屏幕的高

let screenHeight=UIScreen.main.bounds.size.height

let greenView = UIView(frame: CGRect(x: screenWidth-100, y: 0, width: 100, height: 100))

greenView.backgroundColor=UIColor.green

self.window?.addSubview(greenView)

let blueView=UIView(frame: CGRect(x: 0, y: screenHeight-100, width: 100, height: 100))

blueView.backgroundColor=#colorLiteral(red: 0.2392156869, green: 0.6745098233, blue: 0.9686274529, alpha: 1)

self.window?.addSubview(blueView)

let yellowView = UIView(frame: CGRect(x: screenWidth-100, y: screenHeight-100, width: 100, height: 100))

yellowView.backgroundColor=UIColor.yellow

self.window?.addSubview(yellowView)

let purpleView = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))

//purpleView中心點(diǎn)和window中心點(diǎn)重合

purpleView.center=(self.window?.center)!

purpleView.backgroundColor=#colorLiteral(red: 0.5568627715, green: 0.3529411852, blue: 0.9686274529, alpha: 1)

self.window?.addSubview(purpleView)*/

let centerView=UIView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))

centerView.backgroundColor=UIColor.red

self.window?.addSubview(centerView)

//UIView常用屬性

//alpha 透明度 0.0~1.0

centerView.alpha=1.0

//hidden顯示隱形 true? 隱藏 false 顯示

centerView.isHidden=false

//superView獲取到父視圖的屬性

let fatherView=centerView.superview

fatherView?.backgroundColor=UIColor.yellow

//像centerView添加子視圖

let greenView=UIView(frame: CGRect(x: 0, y: 0, width: 150, height: 150))

greenView.backgroundColor=UIColor.green

//子視圖超出父視圖邊界,就把超出部分剪掉

//centerView.clipsToBounds=true

//tag值屬性膊夹,給視圖添加一個(gè)唯一標(biāo)識(shí)

greenView.tag=200

self.window?.addSubview(greenView)

//subView屬性,獲取子視圖屬性

let arr=centerView.subviews

let newView=arr[0]

newView.backgroundColor=UIColor.blue

//根據(jù)tag值獲取視圖對(duì)象

let newView2=centerView.viewWithTag(200)

newView2?.backgroundColor=UIColor.gray

return true

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末捌浩,一起剝皮案震驚了整個(gè)濱河市放刨,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌尸饺,老刑警劉巖进统,帶你破解...
    沈念sama閱讀 222,729評(píng)論 6 517
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異浪听,居然都是意外死亡螟碎,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 95,226評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門(mén)迹栓,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)掉分,“玉大人,你說(shuō)我怎么就攤上這事克伊∷止” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 169,461評(píng)論 0 362
  • 文/不壞的土叔 我叫張陵愿吹,是天一觀的道長(zhǎng)不从。 經(jīng)常有香客問(wèn)我,道長(zhǎng)犁跪,這世上最難降的妖魔是什么消返? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 60,135評(píng)論 1 300
  • 正文 為了忘掉前任载弄,我火速辦了婚禮,結(jié)果婚禮上撵颊,老公的妹妹穿的比我還像新娘宇攻。我一直安慰自己,他們只是感情好倡勇,可當(dāng)我...
    茶點(diǎn)故事閱讀 69,130評(píng)論 6 398
  • 文/花漫 我一把揭開(kāi)白布逞刷。 她就那樣靜靜地躺著,像睡著了一般妻熊。 火紅的嫁衣襯著肌膚如雪夸浅。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 52,736評(píng)論 1 312
  • 那天扔役,我揣著相機(jī)與錄音帆喇,去河邊找鬼。 笑死亿胸,一個(gè)胖子當(dāng)著我的面吹牛坯钦,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播侈玄,決...
    沈念sama閱讀 41,179評(píng)論 3 422
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼婉刀,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了序仙?” 一聲冷哼從身側(cè)響起突颊,我...
    開(kāi)封第一講書(shū)人閱讀 40,124評(píng)論 0 277
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎潘悼,沒(méi)想到半個(gè)月后律秃,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,657評(píng)論 1 320
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡治唤,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,723評(píng)論 3 342
  • 正文 我和宋清朗相戀三年友绝,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片肝劲。...
    茶點(diǎn)故事閱讀 40,872評(píng)論 1 353
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡迁客,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出辞槐,到底是詐尸還是另有隱情掷漱,我是刑警寧澤,帶...
    沈念sama閱讀 36,533評(píng)論 5 351
  • 正文 年R本政府宣布榄檬,位于F島的核電站卜范,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏鹿榜。R本人自食惡果不足惜海雪,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 42,213評(píng)論 3 336
  • 文/蒙蒙 一锦爵、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧奥裸,春花似錦险掀、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 32,700評(píng)論 0 25
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至侠鳄,卻和暖如春埠啃,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背伟恶。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,819評(píng)論 1 274
  • 我被黑心中介騙來(lái)泰國(guó)打工碴开, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人博秫。 一個(gè)月前我還...
    沈念sama閱讀 49,304評(píng)論 3 379
  • 正文 我出身青樓潦牛,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親台盯。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,876評(píng)論 2 361

推薦閱讀更多精彩內(nèi)容