We recommend two learning addresses:
Geek's College Video: http://www.jikexueyuan.com/path/ios/
A blog: http://blog.csdn.net/lizhongfu2013/article/details/29210015
The main want to achieve a mock landing interface
Code:
loginviewcontroller.swift//ibm_login////Created by Dcintern on 6/26/15.//Copyright (c) dcintern. All rights reserved.////import Foundationimport Uikitclass loginviewcontroller:uiviewcontroller{//define attribute var QQNumber = Uitextfield () var passnumber = Uitextfield () override Func Viewdidload () {Self.view.backgroundColor = Uicolor.whit EColor () Super.viewdidload ()//Add head picture [self. addallsubviews ()];} Add all child controls Func addallsubviews () {///tile background var headimage = Uiimageview (Frame:cgrectmake (0,0, +,)) Headi Mage.image = UIImage (named: "123.jpeg") Self.view.addSubview (Headimage)//QQ number input hint, temporarily not used var phonetext = UI Label (Frame:cgrectmake (), Uiscreen.mainscreen () bounds.size.width-60, ()) Phonetext.text = "" Self.view.addS Ubview (Phonetext)///QQ number input box var qqnumber = Uitextfield (Frame:cgrectmake (+, Uiscreen.mainscreen (). Bounds. size.width-60) Qqnumber.placeholder = "username" qqnumber.layer.bOrderwidth = 2 QQNumber.layer.borderColor = Uicolor.lightgraycolor (). Cgcolor QQNumber.layer.cornerRadius = 5 Qqnumber.keyboardtype = Uikeyboardtype.numberpad Self.view.addSubview (qqn umber) self. Qqnumber = qqnumber//password input hint, temporarily useless to var passtext = UILabel (Frame:cgrectmake (). Uiscreen.mainscreen nds.size.width-60) Passtext.text = "" Self.view.addSubview (passtext)//Password input box var passnumber = Uitex Tfield (Frame:cgrectmake (), Uiscreen.mainscreen (), bounds.size.width-60, () Passnumber.placeholder = "Password "PassNumber.layer.borderWidth = 2 PassNumber.layer.borderColor = Uicolor.lightgraycolor (). Cgcolor PassNumber.layer.cornerRadius = 5 Self.view.addSubview (passnumber) self. Passnumber = passnumber///password back var button = UIButton (Frame:cgrectmake ($, I, +)) uibutton.buttonw Ithtype (Uibuttontype.custom) button.settitle ("Forgot password", forState:UIControlState.Normal) Button.settitlecolor (uicolOr.lightgraycolor (), ForState:UIControlState.Normal) Self.view.addSubview (button) Button.addtarget (Self, Action: "O Nclick ", forControlEvents:UIControlEvents.TouchUpInside)}///Password retrieval method implementation Func OnClick () {///Retrieve password hint Uialertview ( Title: "Warm Prompt", message: "New password has been sent to the phone", Delegate:nil, Cancelbuttontitle: "OK", Otherbuttontitles: "Cancel"). Show ()}/** Click on the interface keyboard to resign from the first responder */override func Touchesbegan (Touches:nsset, withevent event:uievent) {self. Qqnumber.resignfirstresponder () self. Passnumber.resignfirstresponder ()}}
iOS mimic QQ Landing interface