七彩霓虹


import UIKit

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

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

// Override point for customization after application launch.


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

self.window?.backgroundColor = UIColor.white

self.window?.makeKeyAndVisible()

self.window?.rootViewController = UIViewController()


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

redView.backgroundColor = UIColor.red

redView.tag = 200

redView.layer.cornerRadius = 207

self.window?.addSubview(redView)

let orangeView = UIView(frame:CGRect(x: 25, y: 186, width: 364, height: 364))

orangeView.backgroundColor = UIColor.orange

orangeView.tag = 201

orangeView.layer.cornerRadius = 182

self.window?.addSubview(orangeView)

let yellowView = UIView(frame:CGRect(x: 50, y: 211, width: 314, height: 314))

yellowView.backgroundColor = UIColor.yellow

yellowView.tag = 202

yellowView.layer.cornerRadius = 157

self.window?.addSubview(yellowView)

let greenView = UIView(frame:CGRect(x: 75, y: 236, width: 264, height: 264))

greenView.backgroundColor = UIColor.green

greenView.tag = 203

greenView.layer.cornerRadius = 132

self.window?.addSubview(greenView)

let youngView = UIView(frame:CGRect(x: 100, y: 261, width: 214, height: 214))

youngView.backgroundColor = #colorLiteral(red: 0.4513868093, green: 0.9930960536, blue: 1, alpha: 1)

youngView.tag = 204

youngView.layer.cornerRadius = 107

self.window?.addSubview(youngView)

let blueView = UIView(frame:CGRect(x: 125, y: 286, width: 164, height: 164))

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

blueView.tag = 205

blueView.layer.cornerRadius = 82

self.window?.addSubview(blueView)

let purpleView = UIView(frame:CGRect(x: 150, y: 311, width: 114, height: 114))

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

purpleView.tag = 206

purpleView.layer.cornerRadius = 57

self.window?.addSubview(purpleView)


//定時(shí)執(zhí)行的間隔? 目標(biāo)對(duì)象? 目標(biāo)對(duì)象選擇執(zhí)行的方法? 用戶信息nil? 是否重復(fù)

Timer.scheduledTimer(timeInterval: 0.3, target: self, selector: #selector(changeColor), userInfo: nil, repeats: true)

return true

}


//MARK:定制器找的目標(biāo)對(duì)象執(zhí)行方法

func? changeColor(){

let redView = self.window?.viewWithTag(200)

//存儲(chǔ)redView的背景顏色

let color = redView?.backgroundColor

self.window?.viewWithTag(200)?.backgroundColor = self.window?.viewWithTag(201)?.backgroundColor

self.window?.viewWithTag(201)?.backgroundColor = self.window?.viewWithTag(202)?.backgroundColor

self.window?.viewWithTag(202)?.backgroundColor = self.window?.viewWithTag(203)?.backgroundColor

self.window?.viewWithTag(203)?.backgroundColor = self.window?.viewWithTag(204)?.backgroundColor

self.window?.viewWithTag(204)?.backgroundColor = self.window?.viewWithTag(205)?.backgroundColor

self.window?.viewWithTag(205)?.backgroundColor = self.window?.viewWithTag(206)?.backgroundColor

self.window?.viewWithTag(206)?.backgroundColor = self.window?.viewWithTag(200)?.backgroundColor

}

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.

}

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.

}

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.

}

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.

}

func applicationWillTerminate(_ application: UIApplication) {

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

}

}

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末哗讥,一起剝皮案震驚了整個(gè)濱河市鸯绿,隨后出現(xiàn)的幾起案子融撞,更是在濱河造成了極大的恐慌溶浴,老刑警劉巖惠险,帶你破解...
    沈念sama閱讀 218,858評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件储藐,死亡現(xiàn)場(chǎng)離奇詭異鹅心,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)互婿,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,372評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)辽狈,“玉大人慈参,你說(shuō)我怎么就攤上這事」蚊龋” “怎么了驮配?”我有些...
    開(kāi)封第一講書人閱讀 165,282評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我壮锻,道長(zhǎng)琐旁,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書人閱讀 58,842評(píng)論 1 295
  • 正文 為了忘掉前任躯保,我火速辦了婚禮旋膳,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘途事。我一直安慰自己验懊,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,857評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布尸变。 她就那樣靜靜地躺著义图,像睡著了一般。 火紅的嫁衣襯著肌膚如雪召烂。 梳的紋絲不亂的頭發(fā)上碱工,一...
    開(kāi)封第一講書人閱讀 51,679評(píng)論 1 305
  • 那天,我揣著相機(jī)與錄音奏夫,去河邊找鬼怕篷。 笑死,一個(gè)胖子當(dāng)著我的面吹牛酗昼,可吹牛的內(nèi)容都是我干的廊谓。 我是一名探鬼主播,決...
    沈念sama閱讀 40,406評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼麻削,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼蒸痹!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起呛哟,我...
    開(kāi)封第一講書人閱讀 39,311評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤叠荠,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后扫责,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體榛鼎,經(jīng)...
    沈念sama閱讀 45,767評(píng)論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,945評(píng)論 3 336
  • 正文 我和宋清朗相戀三年鳖孤,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了借帘。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 40,090評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡淌铐,死狀恐怖肺然,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情腿准,我是刑警寧澤际起,帶...
    沈念sama閱讀 35,785評(píng)論 5 346
  • 正文 年R本政府宣布拾碌,位于F島的核電站,受9級(jí)特大地震影響街望,放射性物質(zhì)發(fā)生泄漏校翔。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,420評(píng)論 3 331
  • 文/蒙蒙 一灾前、第九天 我趴在偏房一處隱蔽的房頂上張望防症。 院中可真熱鬧,春花似錦哎甲、人聲如沸蔫敲。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,988評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)奈嘿。三九已至,卻和暖如春吞加,著一層夾襖步出監(jiān)牢的瞬間裙犹,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 33,101評(píng)論 1 271
  • 我被黑心中介騙來(lái)泰國(guó)打工衔憨, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留叶圃,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 48,298評(píng)論 3 372
  • 正文 我出身青樓践图,卻偏偏與公主長(zhǎng)得像掺冠,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子平项,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,033評(píng)論 2 355

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