Swift Simple Control Example: text box (Uitextfield)

Source: Internet
Author: User

reprint Please declare source: http://blog.csdn.net/jinnchang/article/details/44853487
------------------------------------------------------------------------------------------
viewcontroller.swift//uitextfieldsample////Created by Jinnchang on 15/4/2.//Copyright (c) 2015 Jinn Chang. All rights Reserved.//import Uikitclass Viewcontroller:uiviewcontroller, uitextfielddelegate {var textfield:uite    xtfield! Override Func Viewdidload () {super.viewdidload ()//Do any additional setup after loading the view, typical                Ly from a nib. TextField = Uitextfield (Frame:cgrectmake (+, self.view.frame.size.width-60, +)) Textfield.borderstyle =.                Roundedrect Textfield.placeholder = "Please enter content" Textfield.text = "username" textfield.delegate = self Self.view.addSubview (TextField)} override func didreceivememorywarning () {Super.didreceivememor    Ywarning ()//Dispose of any of the resources that can is recreated.    }//Enter edit state func textfielddidbeginediting (Textfield:uitextfield) {println ("start edit: \ (textfield.text)") }//End Edit State func TextFieldDidendediting (Textfield:uitextfield) {println ("end edit: \ (Textfield.text)")}//Return button to hide keyboard func text        Fieldshouldreturn (Textfield:uitextfield), Bool {Textfield.resignfirstresponder () return True} Click outside the edit box to hide the keyboard override func touchesended (Touches:nsset, withevent event:uievent) {textfield.resignfirstr Esponder ()}}
------------------------------------------------------------------------------------------
Project on GitHub address: uitextfieldsample
Control more related properties and methods reference: Uitextfield Class Reference
Article last updated: April 3, 2015 11:47:37

Swift Simple Control Example: text box (Uitextfield)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.