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, 简单界面的更多相关文章

  1. iOS Swift WisdomHUD 提示界面框架

    iOS Swift WisdomHUD 提示界面框架  Framework Use profile(应用简介) 一:WisdomHUD简介 今天给大家介绍一款iOS的界面显示器:WisdomHUD,W ...

  2. Axure实例演示—登录界面

         实例演示 ——登录界面                                                                                    ...

  3. qt简单界面更新代码(菜鸟级)(部分代码)

    qt简单界面更新代码(菜鸟级)(部分代码)self.timers_1=QtCore.QTimer(self)self.timers_1.timeout.connect(self.min_1)self. ...

  4. Swift - 使用xib添加新界面

    除了使用storyboard外,我们还可以使用xib来设计并创建页面. 1,下面通过一个样例来演示: (1)点击主界面的“信息”按钮,页面切换到信息界面 (2)点击信息界面的“返回”,关闭信息界面,回 ...

  5. Swift下使用Xib设计界面

    虽然Swift可以纯代码设计界面,不过不利用现有的可视化工具有时候有点效率低.下面是使用xib设计方法,部分代码来自网上. (1)新建View 2.新建View class 3.DemoView.sw ...

  6. 【Unity】UGUI系列教程——拼接一个简单界面

    0.简介: 在目前的游戏市场上,手游依然是市场上的主力军,而只有快速上线,玩法系统完善的游戏才能在国内市场中占据份额.而在手游开发过程中,搭建UI系统是非常基本且重要的技能,极端的说如果对Unity的 ...

  7. java简单界面实现

    import javax.swing.JFrame; import javax.swing.JPanel; public class DemoFrame extends JFrame{ public ...

  8. 【QT】利用pyqt5实现简单界面

    Topic: 利用pyqt5编写简单界面Env:win10 + Pycharm2018 + Python 3.6.8Date: 2019/4/29 by hw_Chen2018            ...

  9. iOS开发-使用Storyboard进行界面跳转及传值

    前言:苹果官方是推荐我们将所有的UI都使用Storyboard去搭建,Storyboard也是一个很成熟的工具了.使用Storyboard 去搭建所有界面,我们可以很迅捷地搭建出复杂的界面,也就是说能 ...

随机推荐

  1. 2016-5-19模拟测试 bzoj3652 bzoj3653 bzoj3654

    T1 description 给定正整数\(n\),定义\(f(x) = \max{y \ \mathrm{xor}\ x}(y<n)\) \(x\)在\([0,n)\)随机取值,求\(f(x) ...

  2. MyBatis+Spring 事务管理

                 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 .作者信息和本声明.否则将追究法律责任.http://kinglixing.blog.51cto.com/34 ...

  3. SpringMVC接收页面表单参数(转)

    作者:CN.programmer.Luxh 和java相关 一个普通的表单. 表单的代码如下: <%@ page language="java" contentType=&q ...

  4. hdu2030java

    汉字统计 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissio ...

  5. Java基础知识强化之集合框架笔记63:Map集合之HashMap嵌套ArrayList

    1. ArrayList集合嵌套HashMap集合并遍历. 需求:假设ArrayList集合的元素是HashMap.有3个.每一个HashMap集合的键和值都是字符串.元素我已经完成,请遍历. 结果: ...

  6. IIS Shared Configuration

    Introduction The Internet changes the ways in which companies handle their day-to-day business and h ...

  7. wiki 使用笔记

    Wiki 安装:Linux(Redhat EL5.3)下安装配置MediaWiki wiki配置: 配置文件:DefaultSettings.php  //权限等配置 左边导航条:/wiki/inde ...

  8. <div>相关

    定义 <div>是一个块级元素[会自动换行] 用法 <div>可用于划分独立的一个块状区域,其内部内容显示在<div>的content部分内 结构 [盗用张图] 从 ...

  9. CI框架篇之控制器篇--设置路由(1)

    CodeIgniter 定义默认控制器 当你的网站不存在某个URI 或者 用户直接从根目录访问的时候,CodeIgniter 会加载默认控制器. 打开 application/config/route ...

  10. MITMF使用import error

    安装问题: 1.ubuntu 14.04.安装使用capstone时候,提示出现import error:ERROR: fail to load the dynamic library. 解决方法:将 ...