//
Viewcontroller.swift
QQ Login Interface Layout
//
Created by Yue technology on 15/1/14.
Copyright (c) year BSY. All rights reserved.
//
Import UIKit
Class Viewcontroller:uiviewcontroller {
Defining Properties
var qqnumber = Uitextfield ()
var passnumber = Uitextfield ()
Override Func Viewdidload () {
Self.view.backgroundColor = Uicolor.whitecolor ()
Super.viewdidload ()
Add a head picture
[Self. addallsubviews ()];
}
Add all child controls
Func addallsubviews () {
Avatar
var headimage = Uiimageview (Frame:cgrectmake (50, 30, 220, 200))
Headimage.image = UIImage (named: "Qq.png")
Self.view.addSubview (Headimage)
QQ number 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 = Uitextfield (Frame:cgrectmake (+, Uiscreen.mainscreen (). bounds.size.width-60, 30))
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.addSubview (Qqnumber)
Self. Qqnumber = Qqnumber
Password entry hint
var passtext = UILabel (Frame:cgrectmake (+, Uiscreen.mainscreen (). bounds.size.width-60, 30))
Passtext.text = " Please enter password "
Self.view.addSubview (Passtext)
Password Entry 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 = Uicolor.lightgraycolor (). Cgcolor
PassNumber.layer.cornerRadius = 5
Self.view.addSubview (Passnumber)
Self. Passnumber = Passnumber
Password Recovery
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.addSubview (Button)
Button.addtarget (Self, Action: "OnClick", ForControlEvents:UIControlEvents.TouchUpInside)
}
Password Retrieval method implementation
Func OnClick () {
Retrieve password hint
Uialertview (title: " Warm tip ", message: "The new password has been sent to the phone ", Delegate:nil, Cancelbuttontitle: " OK ", Otherbuttontitles: " cancel "). Show ()
}
/**
Click on the interface keyboard to resign the first responder
*/
Override Func Touchesbegan (Touches:nsset, withevent event:uievent) {
Self. Qqnumber.resignfirstresponder ()
Self. Passnumber.resignfirstresponder ()
}
}
The QQ landing interface layout of Swift development example