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 ...
随机推荐
- flask页面操作gpn接口
https://wizardforcel.gitbooks.io/flask-extension-docs/content http://cabeza.cn/blog/2016/02/28/datat ...
- IE 下的z-index BUG问题
今天做项目的时候在IE7 碰到了IE 的 z-index 问题: 然后问了几个朋友,总结了一下z-index问题的几个要点: 1.z-index 是要在position为relative或者absol ...
- C puzzles详解【26-30题】
第二十六题(不会) The following is a simple program which implements a minimal version of banner command ava ...
- mvc路由设置参数配置类似于url重写
1.新建的mvc项目中Global.asax 2.在另外一个控制器中的视图中 3. 4.
- CSS3实现轮播图效果2
先前用CSS3做了一个一张图片实现的轮播,但是这样的图片很难找,于是又改进了一下. HTML: <div class="box"> <ul> <li& ...
- 通过jquery 获取文本框的聚焦和失焦方法
我还是喜欢用jquery来实现,不管页面中多少个输入框需要实现聚焦,失焦,都公有,我常用的方法是: 遍历该页面中的input框,获取输入框中的val值,当该输入框聚焦的时候跟存放的oldValue值进 ...
- wordpress代理设置
打开wp-config.php,在页首加上以下语句: define('WP_PROXY_HOST', '192.168.84.101'); define('WP_PROXY_PORT', '8080' ...
- 软件工程 speedsnail 第二次冲刺7
20150524 完成任务:蜗牛碰到线后速度方向的调整: 遇到问题: 问题1 方向用到abs等函数,不熟悉 解决1 查看文档 明日任务: 蜗牛碰到线后速度方向的调整:(做优化)
- 遇到Wampserver遇到的问题
- vs C#数据库导入EXCLE
using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using Sy ...