We know that in the App store almost all the software design to the account login, and our most common is QQ, in the absence of stepping into the programmer this no way, see the interface is feeling good tall on the look.
In the process of learning, they follow the mobile phone above the app's own more curious interface to achieve a bit, today to share about the QQ login interface, completely pure code, practical storyboar too troublesome, personal comparison like the implementation of code, and almost all the login interface is almost the same, but the icon is different, Or there will be other expansion functions, but there will be other natto is not a thing.
Nonsense not much to say directly on the code
Import UIKit class Viewcontroller:uiviewcontroller {///define attribute var Qqnumber = Uitextfield () var passnumber = Uitextfi Eld () override Func Viewdidload () {self.view.backgroundColor = Uicolor.whitecolor () supe R.viewdidload ()//Add head picture [self. addallsubviews ()]; }//Add all child controls Func addallsubviews () {///avatar/var headimage = Uiimageview (Frame:cgrectmake (50, 30, ) Headimage.image = UIImage (named: "Qq.png") Self.view.addSubview (Headimage)///QQ No. Input hint//var phonetext = UILabel (Frame:cgrectmake (+, Uiscreen.mainscreen (). bounds.size.width-60, 30))// Phonetext.text = "Please enter QQ number"//self.view.addsubview (phonetext)///QQ number input box var qqnumber = Uitext Field (Frame:cgrectmake (), Uiscreen.mainscreen () bounds.size.width-60, ()) Qqnumber.placeholder = "Please enter QQ number" QQNumber.layer.borderWidth = 1 QQNumber.layer.borderColor = UIColor.lightgraycolor (). Cgcolor QQNumber.layer.cornerRadius = 5 Qqnumber.keyboardtype = Uikeyboardtype.numberpad Self.view.ad Dsubview (Qqnumber) self. Qqnumber = qqnumber//password input prompt//var Passtext = UILabel (Frame:cgrectmake (+, Uiscreen.mainscre En (). bounds.size.width-60, ())//passtext.text = "Please enter password"//self.view.addsubview (passtext)// /Password input box var passnumber = Uitextfield (Frame:cgrectmake (+, Uiscreen.mainscreen (). bounds.size.width-60, 30)) Passnumber.placeholder = "Please enter password" PassNumber.layer.borderWidth = 1 PassNumber.layer.borderColor = Uicolo R.lightgraycolor (). Cgcolor PassNumber.layer.cornerRadius = 5 Self.view.addSubview (passnumber) self. Passnumber = passnumber//password back var button = UIButton (Frame:cgrectmake (200, 360, 120, 30)) Uibutton.buttonwithtype (Uibuttontype.custom) button.settitle ("Forgot password", Forstate:uicontroLstate.normal) Button.settitlecolor (Uicolor.lightgraycolor (), ForState:UIControlState.Normal) Self.view.add Subview (Button) Button.addtarget (Self, Action: "OnClick", 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", Deleg Ate:nil, Cancelbuttontitle: "OK", Otherbuttontitles: "Cancel"). Show ()}/** Click interface keyboard resign First responder */override Func Tou Chesbegan (Touches:nsset, withevent event:uievent) {self. Qqnumber.resignfirstresponder () self. Passnumber.resignfirstresponder ()}}
iOS Development--&QQ login interface for the utility of Swift article