Swift UI
概述


代码如下:
- let label = UILabel(frame:CGRect(origin: CGPointMake(10.0, 50.0), size: CGSizeMake(150,50)))//let 是Swift 表示常量的关键字
- label.text = "This is a Label"
- self.view.addSubview(label)
UILabel创建参数使用了别名,这点像Object-C。
- let btn = UIButton(frame:CGRect(origin: CGPointMake(10.0, 110.0), size: CGSizeMake(150,50)))
- btn.setTitle("button", forState: UIControlState.Normal)
- btn.backgroundColor = UIColor.redColor()
- btn.addTarget(self, action: "buttonClick:", forControlEvents: UIControlEvents.TouchUpInside)
- self.view.addSubview(btn)
- func buttonClick(sender: UIButton!){
- }
- var alert = UIAlertView()
- //直接这样创建有bug
- //var alert = UIAlertView(title: "alert", message: "this is an alert", delegate: self, cancelButtonTitle: "cancel")
- alert.title = "alert"
- alert.delegate = self
- alert.addButtonWithTitle("cancel")
- alert.message = "this is an alert"
- alert.show()
- class ViewController: UIViewController, UIAlertViewDelegate
- //处理alert 的button click
- func alertView(alertView: UIAlertView!, clickedButtonAtIndex buttonIndex: Int){
- println("buttonIndex:\(buttonIndex)")
- }
Swift UI的更多相关文章
- 小波说雨燕 第三季 构建 swift UI 之 UI组件集-视图集(六)Picker View视图 学习笔记
想对PickerView进行操作,只能在代码中操作. 下面 ,再添加三个label组件,然后将所有组件配置到代码中(看代码),然后要实现对PickerView的操作,就要实现它的DataSource协 ...
- Swift UI开发初探
今天凌晨Apple刚刚发布了Swift编程语言,Swift是供iOS和OS X应用编程的新编程语言.相信很多开发者都在学习这门新语言. 废话不多说,下面我就来学习使用Swift创建一个简单的UI应用程 ...
- Swift UI开发初探 (转)
原文地址:http://www.tairan.com/archives/6600 关于Swift语法,可以参考<Apple Swift编程语言入门教程> 效果如下: 开发环境 Xcode6 ...
- 小波说雨燕 第三季 构建 swift UI 之 度假清单 学习笔记
最终的效果: <1>第一个场景: 1.本地化 界面简体中文化 Supporting Files - info.plist Localization native development r ...
- Swift UI控件详细介绍(上)
UI控件 首先介绍一下AppDelegate.swift@UIApplicationMain 调用了OC中的UIApplicationMain函数:UIApplicationMain是iOS应用程序的 ...
- Swift UI学习UITableView and protocol use
Models: UserModel.swift Views: UserInfoCell.swift Controllers: RootViewController.swift, DetailViewC ...
- swift学习:第一个swift ui程序
最近swift有点火,赶紧跟上学习.于是,个人第一个swift程序诞生了... 新建项目
- swift UI专项训练39 用Swift实现摇一摇功能
微信的摇一摇功能想必大家都用过,过春节的时候抢红包也没少摇吧,那么用swift语言怎样实现这么酷炫的功能呢.摇动属于IOS内置可识别的一种动作,在你须要实现摇动功能的viewcontroller中.在 ...
- 小波说雨燕 第三季 构建 swift UI 之 UI组件集-视图集(五)Image View视图 学习笔记
留下两个问题:1.后面涉及到的异常不知道原因.2.动态图片到了程序里面就不动了. 然后: 上面是有问题的,下面是没有问题的了. 代码(另外简单写的代码,纠正了那个错误): imp ...
随机推荐
- Android相关类关系
Activity Window.WindowManager View. interface----ViewManager LayoutInflater Components Activity.Serv ...
- Hunt the Wumpus第二个版本---多怪兽,多洞穴,洞穴间双向互通
其中,将洞穴连起来的算法要好好体会. 学习构建临时变量列表,确认循环用FOR,非确定循环用 WHILE,并定好退出条件. from random import choice cave_numbers ...
- 前端模拟发送数据-Chrome下的REST Client
1)确定需要POST的数据 2)拼接数据,POST给服务器 3)查看服务器响应及结果
- class 类(1)
创建类 #!/usr/bin/env python # coding=utf-8 __metaclass__ = type class Person: def __init__(self, name) ...
- JavaScript 滚动页面到指定元素位置
页面评论功能,当评论较多时,有时须要滚动到评论头部. 能够使用scrollTop方法,加上一点延时动画(animate),可訪问在线演示,代码大体例如以下: <html> <scri ...
- Linux内核设计基础(十)之内核开发与总结
(1)Linux层次结构: (2)Linux内核组成: 主要由进程调度(SCHED).内存管理(MM).虚拟文件系统(VFS).网络接口(NET)和进程间通信(IPC)等5个子系统组成. (3)与Un ...
- ngui点击与场景点击判断
注:NGUI 组件上加上 BoxCollider 并设置区域大小 public void OnMouseDown() { if (UICamera.hoveredObject == null) ...
- AIX 常用命令和知识
BOOTLIST:#bootlist -m normal -o (查看bootlist)#bootlist -m normal (设置bootlist为空,谁要在我机器上执行我就要哭了)#boot ...
- IO中手机旋转事件的传递
UIApplication -> delegate -> widnow -> rootViewController
- 超长英文(代码)自动换行的样式(CSS)
如何想让一连串文字在显示可以自动换行,而不会把在代码中使用的容器撑开,则在文章的CSS样式处加上以下代码即可: table-layout: fixed; word-wrap:break-word;或者 ...