//

// ViewController.swift

// UILabelTest

//

// Created by mac on 15/6/23.

// Copyright (c) 2015年 fangyuhao. All rights reserved.

//

import UIKit

class ViewController: UIViewController,UITextFieldDelegate {

override func viewDidLoad() {
super.viewDidLoad() var textField = UITextField(frame: CGRectMake(10, 160, 200, 30))
textField.borderStyle = UITextBorderStyle.RoundedRect
//设置文本样式
textField.placeholder = "请输入用户名"//设置提示文字
textField.text = "holyantholyantholyantho"
textField.adjustsFontSizeToFitWidth = true
textField.minimumFontSize = 14//指定最小可缩小的字号
textField.textAlignment = NSTextAlignment.Center//设置对其方式
//键盘设置
textField.returnKeyType = UIReturnKeyType.Go//设置return建属性
textField.delegate = self
//清除按钮
textField.clearButtonMode = UITextFieldViewMode.WhileEditing
//背景设置
textField.background = UIImage(named: "background") self.view.addSubview(textField) // Do any additional setup after loading the view, typically from a nib.
} override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
} func textFieldShouldReturn(textField: UITextField) -> Bool {
//收起键盘
textField.resignFirstResponder()
println(textField.text)
return true
}

}

UITextField swift的更多相关文章

  1. swift系统学习控件篇:UIbutton+UIlabel+UITextField+UISwitch+UISlider

    工作之余,学习下swift大法.把自己的学习过程分享一下.当中的布局很乱,就表在意这些细节了.直接上代码: UIButton+UILabel // // ViewController.swift // ...

  2. Swift - 文本输入框(UITextField)

    1,文本框的创建,有如下几个样式: UITextBorderStyle.none:无边框 UITextBorderStyle.line:直线边框 UITextBorderStyle.roundedRe ...

  3. Swift - 文本输入框(UITextField)的用法

    1,文本框的创建,有如下几个样式: UITextBorderStyle.None:无边框 UITextBorderStyle.Line:直线边框 UITextBorderStyle.RoundedRe ...

  4. Swift基础之UITextField

    //设置全局变量,将下面的替换即可     //var myTextField = UITextField();     //系统生成的viewDidLoad()方法     override fun ...

  5. swift 实践- 05 -- UITextField

    import UIKit class ViewController: UIViewController ,UITextFieldDelegate{ // 文本框的创建, 有如下几个样式: // UIT ...

  6. swift中的UITextField

    let userTF = UITextField(frame: CGRectMake(,,,)) userTF.backgroundColor = UIColor.redColor() // 输入框样 ...

  7. iOS 8 swift 键盘不出来 ios 8 uitextfield keyboard not appearing

    ios 8 uitextfield keyboard not appearing //发现在iphone 6 and iPhone plus 上面键盘不出来.后来查了下原来要在模拟器里设置下 var ...

  8. swift UITextfield 添加点击方法 - 简单实现

    1. 真正在任何系统上都有效的方法 1./// 城市选择 private lazy var cityTextfield:UITextField = { let tf = UITextField() t ...

  9. swift - UITextField 的用法

    1,文本框的创建,有如下几个样式: public enum UITextBorderStyle : Int {     case none 无边框     case line 直线边框     cas ...

随机推荐

  1. LiveView 0.8 RC1 could boot evidence files acquired from Win10 64bit

    The latest Windows 10 will be more and more popular in the very near future. Now let's take a look i ...

  2. c89和c99的区别【转】

    //本文转自:http://www.360doc.com/content/10/0324/18/2633_20101093.shtml 注: GCC支持C99, 通过 --std=c99 命令行参数开 ...

  3. 浅谈Bootstrap自适应功能在Web开发中的应用

    随着移动端市场的强势崛起,web的开发也变得愈发复杂,对于个体开发者来说,自己开发的网站,在电脑.手机.Pad等上面都要有正常的显示以及良好的用户体验.如果每次都要自己去调整网页去匹配各个不同的客户端 ...

  4. linux系统下将php和mysql命令加入到环境变量中的方法

    在Linux CentOS系统上安装完php和MySQL后,为了使用方便,需要将php和mysql命令加到系统命令中,如果在没有添加到环境变量之前,执行 “php -v”命令查看当前php版本信息时时 ...

  5. u-boot board_uart_init流程

    /** ****************************************************************************** * @author    Maox ...

  6. Apache开启Proxy代理,实现域名端口转发

    今天帮客户迁移网站,客户一个是ASPX的一个是PHP的网站,这时候有2个域名,可是php网站是Apache下的伪静态,必须要用到Apache,但是ASPX网站还必要到IIS+Mssql 然后到了这个时 ...

  7. kettle教程(1) 简单入门、kettle简单插入与更新。打开kettle

    本文要点:Kettle的建立数据库连接.使用kettle进行简单的全量对比插入更新:kettle会自动对比用户设置的对比字段,若目标表不存在该字段,则新插入该条记录.若存在,则更新.   Kettle ...

  8. PHP导出excel文件

    现在教教你如何导入excel文件: 在我的文件储存里面有一个com文件夹的,将其解压放在ThinkPHP/Library/文件夹里面,然后就是写控制器啦!去调用这个插件: <?php names ...

  9. Python pass 语句使用示例

    Python pass 语句的使用方法示例.Python pass是空语句,pass语句什么也不做,一般作为占位符或者创建占位程序,是为了保持程序结构的完整性,pass语句不会执行任何操作,比如: P ...

  10. centos yum 安装问题

    yum [Errno 256] No more mirrors to try 解决方法 输入下面的命令即可解决问题: yum clean all yum makecache 导致 centos安装软件 ...