Swift-UIButton&AlertView
来源:互联网 发布:jquery和js区别 编辑:程序博客网 时间:2024/06/05 16:20
大家看到题目应该就知道我要说的东西了,今天要给大家介绍button控件,也是比较常用的用法。我就不啰嗦什么了。直接上代码:
var myButton:UIButton!
//Attention: buttonWithType return the type of AnyObject
myButton =UIButton.buttonWithType(.System)as? UIButton(这里有必要说明一下,buttonWithType最终返回的是一个AnyObject,所以这里要用到类型转换)
//Set the location and size of button
myButton.frame =CGRectMake(110,70, 200, 100)
//Add a name to button,and set state
myButton.setTitle("Press Me", forState: .Normal)
myButton.setTitle("I`m Pressed", forState: .Highlighted)
//Add action to button
myButton.addTarget(self, action:"buttonIspressed:", forControlEvents: .TouchDown)
myButton.addTarget(self, action:"buttonIsTaped:", forControlEvents: .TouchUpInside)
//Add backgroundColor
myButton.backgroundColor =UIColor.greenColor()
//Add image to backgound of myButton
var image = UIImage(named:"pg.jpg")
myButton.setBackgroundImage(image, forState: .Normal)
view.addSubview(myButton)
到这里button的用法差不多就讲完了。下面我要说的是AlertView,不是AlertViewController。大家看仔细:
myAlertView =UIAlertView(title: "Done", message: "The button is tapped", delegate:self, cancelButtonTitle: "Cancell", otherButtonTitles: "ok")
myAlertView!.show()
Ok,今天就说这么多了。明天一个下载图片的demo,最近做项目要用。
- Swift-UIButton&AlertView
- swift UIButton
- Swift UIButton
- swift uibutton
- UIButton swift
- swift UIButton
- swift UIButton
- Swift AlertView 弹出警告框
- Swift 实现alertView协议实现
- ios swift Button, Label, AlertView
- iOS-YHAlertView(自定义AlertView,Swift版)
- swift UIButton使用
- swift UIButton的使用
- swift UIButton的使用
- Swift创建UIButton
- swift之UIButton
- Swift 创建UIButton
- Swift UIButton UIButtonType
- Pow(x, n)
- java.sql.DriverManager
- 【BZOJ 3576】 [Hnoi2014]江南乐
- Android 深入理解Android中的自定义属性
- 如何简单快速调试高大上的谷歌浏览器
- Swift-UIButton&AlertView
- Android 你应该知道的学习资源 进阶之路贵在坚持
- 使用Eclipse创建Maven项目报错
- Socket编程(多线程、双向通信)
- ajax引擎demo和ajax运作过程浅析
- 开源中国iOS客户端学习——MBProgressHUD特效
- 百度地图api的url请求的参数规则
- adb命令查看包名和adb启动你的apk
- 为向量法求组合问题