iOS:Swift界面实例1, 简单界面
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 @UIApplicationMain
class 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 = var labelHello = UILabel(frame: CGRectMake(EDGE, (frame.height - EDGE)/, frame.width - EDGE * , 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.运行
iOS:Swift界面实例1, 简单界面的更多相关文章
- iOS Swift WisdomHUD 提示界面框架
iOS Swift WisdomHUD 提示界面框架 Framework Use profile(应用简介) 一:WisdomHUD简介 今天给大家介绍一款iOS的界面显示器:WisdomHUD,W ...
- Axure实例演示—登录界面
实例演示 ——登录界面 ...
- qt简单界面更新代码(菜鸟级)(部分代码)
qt简单界面更新代码(菜鸟级)(部分代码)self.timers_1=QtCore.QTimer(self)self.timers_1.timeout.connect(self.min_1)self. ...
- Swift - 使用xib添加新界面
除了使用storyboard外,我们还可以使用xib来设计并创建页面. 1,下面通过一个样例来演示: (1)点击主界面的“信息”按钮,页面切换到信息界面 (2)点击信息界面的“返回”,关闭信息界面,回 ...
- Swift下使用Xib设计界面
虽然Swift可以纯代码设计界面,不过不利用现有的可视化工具有时候有点效率低.下面是使用xib设计方法,部分代码来自网上. (1)新建View 2.新建View class 3.DemoView.sw ...
- 【Unity】UGUI系列教程——拼接一个简单界面
0.简介: 在目前的游戏市场上,手游依然是市场上的主力军,而只有快速上线,玩法系统完善的游戏才能在国内市场中占据份额.而在手游开发过程中,搭建UI系统是非常基本且重要的技能,极端的说如果对Unity的 ...
- java简单界面实现
import javax.swing.JFrame; import javax.swing.JPanel; public class DemoFrame extends JFrame{ public ...
- 【QT】利用pyqt5实现简单界面
Topic: 利用pyqt5编写简单界面Env:win10 + Pycharm2018 + Python 3.6.8Date: 2019/4/29 by hw_Chen2018 ...
- iOS开发-使用Storyboard进行界面跳转及传值
前言:苹果官方是推荐我们将所有的UI都使用Storyboard去搭建,Storyboard也是一个很成熟的工具了.使用Storyboard 去搭建所有界面,我们可以很迅捷地搭建出复杂的界面,也就是说能 ...
随机推荐
- Linux中的文件压缩,打包和备份命令
压缩解压命令 gzip 文件 -c : 将压缩数据输出到屏幕,可用来重定向 -v 显示压缩比等信息 -d 解压参数 -t 用来检验一个压缩文件的一致性看看档案有没错 -数字 : 压 ...
- Java集合类总结
Java的集合类关系图,摘自网络: List: 1,ArrayList:内部采用数组存储结构:随机查找效率高,增删效率低:线程不安全: 2,LinkedList:内部采用链表存储结构:增删效率高,查找 ...
- runnable:在线IDE+代码片段分享
在我之前的博客20个最好的在线IDE中列举过很多在线IDE,可以很方便的在云端执行代码,这样在你手头没有编译器时想试个小程序会非常有用. 今天介绍的这个网站runnable把在线IDE和代码片段结合了 ...
- Gamma校正及其OpenCV实现
參考:[1]http://www.cambridgeincolour.com/tutorials/gamma-correction.htm [2]http://en.wikipedia.org/wik ...
- Android网络:HTTP之利用HttpURLConnection访问网页、获取网络图片实例 (附源码)
http://blog.csdn.net/yanzi1225627/article/details/22222735 如前文所示的TCP局域网传送东西,除了对传输层的TCP/UDP支持良好外,Andr ...
- Linux下设置最大文件打开数nofile及nr_open、file-max
在开发运维的时候我们常常会遇到类似“Socket/File: Can’t open so many files”,“无法打开更多进程”,或是coredump过大等问题,这些都可以设置资源限制来解决.今 ...
- kafka Windows客户端Linux服务器---转
原文:http://blog.csdn.net/jingshuigg/article/details/25001979 一.对于服务器端的搭建可以参考上一篇文章:kafka单机版环境搭建与测试 服务器 ...
- Android(java)学习笔记177:BroadcastReceiver之 应用程序安装和卸载 的广播接收者
国内的主流网络公司(比如网易.腾讯.百度等等),他们往往采用数据挖掘技术获取用户使用信息,从而采用靶向营销.比如电脑上,我们浏览网页的时候,往往会发现网页上会出现我们之前经常浏览内容的商 ...
- Android 高级UI设计笔记01:使用ExpandableListView组件(ListView的扩展)
1.ExpandableListView是一个用来显示二级节点的ListView. 比如如下效果的界面: 2.使用ExpandableListView步骤 (1)要给ExpandableListVie ...
- android 5.0 创建多用户 双开多开应用(1)
Andriod5.0多用户 双开应用 android多用户是5.0之后有的,类似windows的账户系统 不过官方还没有完全确认,API大都是hide状态 我这里提供一种方式并不适用所有的,由于我们有 ...