//

// 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. webGL 学习教程

    ====教程=================== webGL中文网:http://www.hewebgl.com/webGL API:https://developer.mozilla.org/en ...

  2. Android knock code analysis

    My colleague she forgot the knock code and ask me for help. I know her phone is LG G3 D855 with Andr ...

  3. javascript ES5 Object对象

    原文:http://javascript.ruanyifeng.com/stdlib/object.html 目录 概述 Object对象的方法 Object() Object.keys(),Obje ...

  4. HTML框架标签

    与HTML框架有关的标签主要有三种: <frameset>框架结构标签 <frame>框架标签 <iframe>内联框架标签 一. 先来说第一种框架结构标签 < ...

  5. MVC 项目 在前台使用DataTable

    1:后台控制器代码 //CreateTestOutputDataHeader生成一个测试DataTable public ActionResult UseDataTable() { DataTable ...

  6. ctags对部分目录生成tags

    最近在研究Tiny6410上的uboot移植,看uboot源码时,生成tags文件用的是最粗暴的方法:“ctags -R *”,由于某些函数在各个平台下都有实现,导致在用“g+]”跳转到该函数的定义时 ...

  7. css3 文本效果

    CSS3 文本效果   1 CSS3 文本阴影在 CSS3 中,text-shadow 可向文本应用阴影,能够规定水平阴影.垂直阴影.模糊距离,以及阴影的颜色.text-shadow: 5px 5px ...

  8. <b>和<strong>标签区别

    简单说, strong是web标准中xhtml的标签,加强语气,起强调作用(默认是采用加粗来实现强调),逻辑标签: b 是html的,bold粗体. web标准主张xhtml不涉及具体的表现形式,“强 ...

  9. c#中操作word文档-四、对象模型

    转自:http://blog.csdn.net/ruby97/article/details/7406806 Word对象模型  (.Net Perspective) 本文主要针对在Visual St ...

  10. Yii整合ZF2及soap实例

    一)如何整合? // change the following paths if necessary $yii = dirname(__FILE__).'/framework/yii.php'; $c ...