UITextField swift
//
// 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的更多相关文章
- swift系统学习控件篇:UIbutton+UIlabel+UITextField+UISwitch+UISlider
工作之余,学习下swift大法.把自己的学习过程分享一下.当中的布局很乱,就表在意这些细节了.直接上代码: UIButton+UILabel // // ViewController.swift // ...
- Swift - 文本输入框(UITextField)
1,文本框的创建,有如下几个样式: UITextBorderStyle.none:无边框 UITextBorderStyle.line:直线边框 UITextBorderStyle.roundedRe ...
- Swift - 文本输入框(UITextField)的用法
1,文本框的创建,有如下几个样式: UITextBorderStyle.None:无边框 UITextBorderStyle.Line:直线边框 UITextBorderStyle.RoundedRe ...
- Swift基础之UITextField
//设置全局变量,将下面的替换即可 //var myTextField = UITextField(); //系统生成的viewDidLoad()方法 override fun ...
- swift 实践- 05 -- UITextField
import UIKit class ViewController: UIViewController ,UITextFieldDelegate{ // 文本框的创建, 有如下几个样式: // UIT ...
- swift中的UITextField
let userTF = UITextField(frame: CGRectMake(,,,)) userTF.backgroundColor = UIColor.redColor() // 输入框样 ...
- iOS 8 swift 键盘不出来 ios 8 uitextfield keyboard not appearing
ios 8 uitextfield keyboard not appearing //发现在iphone 6 and iPhone plus 上面键盘不出来.后来查了下原来要在模拟器里设置下 var ...
- swift UITextfield 添加点击方法 - 简单实现
1. 真正在任何系统上都有效的方法 1./// 城市选择 private lazy var cityTextfield:UITextField = { let tf = UITextField() t ...
- swift - UITextField 的用法
1,文本框的创建,有如下几个样式: public enum UITextBorderStyle : Int { case none 无边框 case line 直线边框 cas ...
随机推荐
- SOS 调试扩展 (SOS.dll) 《第五篇》
一.SOS扩展命令 SOS包含几十个命令,要熟练使用SOS,首先要了解SOS有哪些命令.下面给出SOS命令列表. 命令 描述 BPMD [<module name> <method ...
- 拿搬东西来解释udp tcpip bio nio aio aio异步
[群主]雷欧纳德简单理解 tcpip是有通信确认的面对面通信 有打招呼的过程 有建立通道的过程 有保持通道的确认 有具体传输udp是看到对面的人好像在对面等你 就往对面扔东西[群主]雷欧 ...
- boost:exception使用实例
/************************************************************************/ /*功能描述: boost exception使用 ...
- Python之路【第二篇】:Python基础(一)
一.作用域 对于变量的作用域,执行声明并在内存中存在,该变量就可以在下面的代码中使用. 1 2 3 if 1==1: name = 'wupeiqi' print name 下面的结论对吗? ...
- typedef 及其与struct的结合使用
//相当于为现有类型创建一个别名,或称类型别名. //整形等 typedef int size; //字符数组 ]; ];//=> typedef ]; Line text, secondlin ...
- [视频]ARM告诉你物联网怎么玩,mbed 6LoWPan demo
该视频演示了基于arm mbed的物联网设备间的6LoWPAN应用,如连接家里的土壤湿度传感器,灯光控制,安防联动等应用. 演示视频 原创文章,转载请注明: 转载自 http://www. ...
- jQuery实现的Div窗口震动效果实例
本文实例讲述了jQuery实现的Div窗口震动效果.分享给大家供大家参考.具体如下: 这是一款jQuery窗口震动效果代码,在Div边框内点击一下鼠标,它就开始震动了,适用浏览器:IE8.360.Fi ...
- oracle的表名、字段名、constraint名的长度限制分别是多少?
文章出处:http://blog.csdn.net/haiross/article/details/38379615 Oracle:表名.字段名.constraint名的长度有限制 oracle 的命 ...
- phpmyadmin误删表后的恢复过程(心惊胆跳啊)
话说今天不知道是抽风了还是失魂了,在用phpmyadmin删除测试数据时,竟然将整个表删除了: 等程序运行出错时,才出现整个表都没有了,而且之前也没有备份好!这下蛋疼了,这个可是production服 ...
- setting菜单界面的形成--未优化
代码: first_preference.xml: <?xml version="1.0" encoding="utf-8"?> <Prefe ...