//

// 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. 深入了解Qt(二)之元对象系统(Meta-Object System)

    深入了解Qt主要内容来源于Inside Qt系列,本文做了部分删改,以便于理解.在此向原作者表示感谢! 在Qt Meta Object System-元对象系统这篇文章中,从底层实现的源码剖析了元对象 ...

  2. 如何避免遭受HTTS中间人攻击

    先前为大家说明了如何对App的HTTPS通讯进行中间人攻击,听起来很吓人吧-表示若是使用手机的网银或购物等App,便有可能暴露在风险之中. 会发生HTTPS遭受拦截的主要原因是客户端的App未对服务器 ...

  3. XML处理

    //生成XML XmlDocument xmlDoc = new XmlDocument(); XmlElement root = xmlDoc.CreateElement("Data&qu ...

  4. mq队列管理器命令

    dspmq: 队列管理器显示 QMCIPSA-------队列管理器 runmqsc QMSAA  运行查找Q队列名 运行MQ命令 runmqsc QmgrName 如果是默认队列管理器,可以不带其名 ...

  5. 比较合并工具vimdiff的主要用法归纳

    参考:https://www.ibm.com/developerworks/cn/linux/l-vimdiff/ vimdiff主要用法归纳如下:   1.打开文件 vimdiff file1 fi ...

  6. 标签栏控制器(UITabBarController)

    一.标签栏控制器基础 1.绪论 a.一个标签栏是一个独立的界面对象,它经常与一个视图控制器(UITabBarController是UIViewController的子类)一起使用. b.一个标签栏项目 ...

  7. HTML的结束标签问题

    根据w3c的原则,xml的每个开始标签必须有一个结束标签与之对应,也就是<html>必须要有</html>结束,才是一个完整的元素,除非它是一个自封闭标签,自封闭就是<i ...

  8. LogStash 中字段的排除和数据的排除

    排除字段 字段的排除需要在filter中进行操作,使用一个叫做 mutate 的工具,具体操作如下 由于这个工具的名字不是很容易联想到,也是找了好一会. //比如我们可能需要避免日志中kafka的一些 ...

  9. arcgis api for javascript 3.16开发(一)

    原来一直都在用Flex开发arcgis的地图接口,用的时间很长,用的习惯也顺手,可Flex这个开发工具已经基本要淘汰了,并且地图借助flash的方式加载在浏览器里已经不能适应webgis的快速开发需求 ...

  10. Google账户无法登陆-Solved

    Author:KillerLegend Date:2014.5.19 From:http://www.cnblogs.com/killerlegend/p/3737888.html 这几天不知道怎么回 ...