SWIFT Button的基本用法
import UIKit @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
// Override point for customization after application launch.
self.window!.backgroundColor = UIColor.whiteColor()
self.window!.rootViewController = RootViewController()
self.window!.makeKeyAndVisible()
return true
} }
import UIKit
class RootViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
//初始化button
let btn = UIButton(type: UIButtonType.Custom)
//尺寸
btn.frame = CGRect(x: , y: , width: , height: )
//背景颜色
btn.backgroundColor = UIColor.redColor()
//设置标题
btn.setTitle("按钮", forState: UIControlState.Normal)
//设置标题的颜色
btn.setTitleColor(UIColor.greenColor(), forState: UIControlState.Normal)
//添加点击事件
btn.addTarget(self, action: "printSomeThing:", forControlEvents: UIControlEvents.TouchUpInside)
//self.view加载子视图btn
self.view.addSubview(btn)
}
//点击按钮执行的方法
func printSomeThing(button:UIButton){
print(button)
}
}
SWIFT Button的基本用法的更多相关文章
- swift button一些简单设置
1,按钮的创建(1)按钮有下面四种类型: UIButtonType.ContactAdd:前面带“+”图标按钮,默认文字颜色为蓝色,有触摸时的高亮效果 UIButtonType.DetailDiscl ...
- Swift枚举的全用法
鉴于昨天开会部门会议讨论的时候,发现有些朋友对枚举的用法还是存在一些疑问,所以就写下这个文章,介绍下Swift下的枚举的用法. 基本的枚举类型 来,二话不说,我们先贴一个最基本的枚举: enum Mo ...
- Swift—UITextField的基本用法
https://www.jianshu.com/p/63bdeca39ddf 1.文本输入框的创建##### let textField = UITextField(frame: CGRect(x:1 ...
- SWIFT UITableView的基本用法
import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: ...
- MFC radio button 绑定变量用法
我们在对话框中拖动一个radio button控件,然后点击类向导,结果却发现在Member Variables里看不到Radio控件的ID.这是为什么? 2.1 三个Radio Button,ID分 ...
- 【iOS】swift 排序Sort函数用法(包含NSDictionary排序)
用了几分钟做的简单翻译 一个例子 直接贴代码,不过多解释 //这是我们的model class imageFile { var fileName = String() var fileID = Int ...
- swift中_的用法,忽略默认参数名。
swift中默认参数名除了第一个之外,其他的默认是不忽略的,但是如果在参数的名字前面加上_,就可以忽略这个参数名了,虽然有些麻烦,但是这种定义也挺好,而且不想知道名字或者不想让别人知道名字的或者不用让 ...
- Swift String 一些经常用法
直接上代码 //字符串 //1 推断字符串是否为空 var test1Str="" var test1Str2:String = String(); println("t ...
- Swift 字典 Dictionary基本用法
import UIKit /* 字典的介绍 1.字典允许按照某个键访问元素 2.字典是由两部分组成, 一个键(key)集合, 一个是值(value)集合 3.键集合是不能有重复的元素, 值集合可以有重 ...
随机推荐
- easyui datagrid 列隐藏和显示
easyui datagrid 列隐藏和显示 用js怎么控制列的显示和隐藏? 最佳答案 $('#grid').datagrid('hideColumn','列field');把hideColu ...
- Nvidia VertexTextureFetch Water
http://http.download.nvidia.com/developer/SDK/Individual_Samples/samples.html http://http.download.n ...
- 10. 求N分之一序列前N项和
求N分之一序列前N项和 #include <stdio.h> int main() { int i, n; double item, sum; while (scanf("%d& ...
- PHP 错误与异常 笔记与总结(6)将错误日志保存在系统日志中
[将错误记录到系统日志中] 在 php.ini 中将 error_log 设置为: error_log = syslog 或者在运行时使用 ini_set() 函数设置. [例1] <?php ...
- mysql没有delete操作,那是delete from操作,
1.mysql没有delete操作,那是delete from操作, 2.DELETE FROM table_name [WHERE Clause]
- journalctl --help
journalctl [OPTIONS...] [MATCHES...] Query the journal. Flags: --system Show the sy ...
- JS采用正则表达式简单获取URL地址栏参数
GetUrlParam:function GetUrlParam(param){ var reg = new RegExp("(^|&)"+ param +"=( ...
- 如何用Apache TCPMon来截获SOAP消息
在WebService服务器和客户机之间会传递SOAP消息,有时我们需要得到这些消息以便调试,而Apache的TCPMon可以帮助我们做到这一点. TCPMon的下载地址在http://ws.apa ...
- 【No.2 Ionic】Android打包
项目做完之后 接下来就是打包操作了,接下来直接说Android 打包操作 生成签名证书 keytool -genkey -alias vincentguo -keyalg RSA -validity ...
- autowire异常的三个情况
2010-3-11 16:06:00 net.sf.ehcache.config.ConfigurationFactory parseConfiguration 警告: No configuratio ...