美文网首页
练习代码day1

练习代码day1

作者: 京西 | 来源:发表于2016-11-18 17:10 被阅读0次

//应用程序代理类

//AppDelegate中的方法都是UIApplicationDelegatez的协议方法

//应用程序类

class AppDelegate: UIResponder, UIApplicationDelegate {

//应用程序窗口,是 AppDelete类的属性

var window: UIWindow?

//应用程序加载完成触发这个方法

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

// Override point for customization after application launch.

//想再window对象添加对象,就在这个方法中实现

//屏幕类UIScreen

//UIScreen.main获取屏幕对象

//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)

//让Window成为应用程序的主窗口,并使其可见

self.window?.makeKeyAndVisible()

//给window设置跟试图控制器(现在制作了解)

self.window?.rootViewController=UIViewController()

//一般应用程序只有一个window对象

return true

}

//应用程序将要取消活跃状态是触发

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:.

}

}

何敏  14:54:55

class AppDelegate: UIResponder, UIApplicationDelegate {

//应用程序窗口,是 AppDelete类的属性

var window: UIWindow?

//应用程序加载完成触发这个方法

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

// Override point for customization after application launch.

//想再window对象添加对象,就在这个方法中实现

//屏幕类UIScreen

//UIScreen.main获取屏幕对象

//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)

//让Window成为应用程序的主窗口,并使其可见

self.window?.makeKeyAndVisible()

//给window设置跟试图控制器(现在制作了解)

self.window?.rootViewController=UIViewController()

//一般应用程序只有一个window对象

//UiView 创建方式

/*

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添加一个子视图

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中心点和window中心点重合

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值属性,给视图添加一个唯一标识

greenView.tag=200

self.window?.addSubview(greenView)

//subView属性,获取子视图属性

let arr=centerView.subviews

let newView=arr[0]

newView.backgroundColor=UIColor.blue

//根据tag值获取视图对象

let newView2=centerView.viewWithTag(200)

newView2?.backgroundColor=UIColor.gray

return true

}

相关文章

  • 2022-04-22

    day1 markdown语法学习-罗wb 已学内容汇总 代码练习 代码分行 代码不分行 A表示95-100,C表...

  • 练习代码day1

    //应用程序代理类 //AppDelegate中的方法都是UIApplicationDelegatez的协议方法 ...

  • 2020.2.1 R语言|Practice1

    一、Day1今天的学习任务: 1.R语言的基础语法检验 2.统计可视化代码练习 3.Jimmy生信技能树B站R系列...

  • 代码代码day1

    Mar.23 题目 Write a program that concatenates two linked li...

  • 禅绕画练习201703

    【Day1】20170314初识禅绕:线的练习 【Day2】20170315

  • 无标题文章

    # Markdown 练习 ## 关于代码书写的练习 ###粘贴代码

  • 2017.12.7

    一直在练习代码编写。简单的代码练习。

  • 2018-08-11 树 夜晚给树加了滤镜

    暑假练习手绘稿打卡 DAY1 没带很多马克笔 颜色有点点怪

  • 《老人与海》翻译练习

    ~《老人与海》翻译练习 Day1 原文:https://gutenberg.ca/ebooks/hemingwa...

  • 代码练习

    字号,字体颜色alt推广标签 title备注图片名称 居中意思 结束端 一:头部TDK altlogo处是...

网友评论

      本文标题:练习代码day1

      本文链接:https://www.haomeiwen.com/subject/lbhspttx.html