iOS:Swift界面实例1, 简单界面
来源:互联网 发布:尚观linux视频 百度云 编辑:程序博客网 时间:2024/06/06 03:12
Apple推出了基于Objective-C的新语言Swift. 通过实例, 我们可以很好的感受这门新语言
注意事项: 在XCode6_Beta中, 如果有中文, IDE的自动补全功能就会失效, 所以开始调试的时候可以先用英文, 后面再用中文替代.
1. 新建iOS -> Single View Application.
2. 修改AppDelegate.swift文件
//// AppDelegate.swift// UIByCode_Swift_1_HelloWorld//// Created by yao_yu on 14-6-18.// Copyright (c) 2014 yao_yu. All rights reserved.//import UIKit@UIApplicationMainclass AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool { self.window = UIWindow(frame: UIScreen.mainScreen().bounds) // Override point for customization after application launch. let window = self.window! window.backgroundColor = UIColor.whiteColor() window.makeKeyAndVisible() let frame = UIScreen.mainScreen().bounds let EDGE:CGFloat = 20 var labelHello = UILabel(frame: CGRectMake(EDGE, (frame.height - EDGE)/2, frame.width - EDGE * 2, EDGE)) labelHello.textAlignment = NSTextAlignment.Center labelHello.text = "你好,欢迎来到swift世界!" //加入中文后,XCode的自动补全功能就不出来了 window.addSubview(labelHello) 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 throttle down OpenGL ES frame rates. 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 inactive 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:. }}
3. 运行
0 0
- iOS:Swift界面实例1, 简单界面
- Swift 写一个简单界面
- ios简单登陆界面
- Swift 界面
- Android简单界面实例分析
- swift入门-实现简单的登录界面
- ios开发swift跳转设置密码界面
- IOS(swift)中用代码创建UI界面
- swift 编写欢迎界面-- ios开发
- iOS动态启动界面(swift实现)
- Swift实现IOS界面的跳转
- swift 编写欢迎界面-- ios开发
- Swift实现IOS界面的跳转
- java图像界面开发简单实例
- IOS二维码拍照相机自定义界面实例
- IOS二维码拍照相机自定义界面实例
- IOS二维码拍照相机自定义界面实例
- IOS 实例一 登录注册界面搭建
- HDU 1253 胜利大逃亡 NYOJ 523【BFS】
- 机器大端,小端的判别及int ,long, long long 尺寸大小的判别
- 两个Fragment之间的跳转
- 第九节swift 三元操作符 主标签
- Android开发详解之onTouch和onClick详解
- iOS:Swift界面实例1, 简单界面
- 成员变量和局部变量的区别
- g++编译命令选项
- OpenCV中HOG+SVM物体分类
- Android requires compiler compliance level 5.0 or 6.0. Found '1.4' instead的解决办法
- jquery常见的操作(以后追加)
- IO相关知识复习三
- 携程决赛D题 最小割
- %~dp0的意义