QQ login interface layout of SWift development instances and swift instance interface Layout
//
// ViewController. swift
// QQ logon interface Layout
//
// Created by yueda Technology on 15/1/14.
// Copyright (c) 2015 BSY. All rights reserved.
//
Import UIKit
Class ViewController: UIViewController {
/// Define attributes
Var QQNumber = UITextField ()
Var PassNumber = UITextField ()
Override func viewDidLoad (){
Self. view. backgroundColor = UIColor. whiteColor ()
Super. viewDidLoad ()
// Add a header Image
[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 prompt
Var phoneText = UILabel (frame: CGRectMake (30,240, UIScreen. mainScreen (). bounds. size. width-60, 30 ))
PhoneText. text = "Enter the QQ number"
Self. view. addSubview (phoneText)
/// QQ number input box
Var QQNumber = UITextField (frame: CGRectMake (30,270, UIScreen. mainScreen (). bounds. size. width-60, 30 ))
QQNumber. placeholder = "Enter the 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 Input prompt
Var passText = UILabel (frame: CGRectMake (30,300, UIScreen. mainScreen (). bounds. size. width-60, 30 ))
PassText. text = "enter the password"
Self. view. addSubview (passText)
/// Password input box
Var PassNumber = UITextField (frame: CGRectMake (30,330, UIScreen. mainScreen (). bounds. size. width-60, 30 ))
PassNumber. placeholder = "enter the password"
PassNumber. layer. borderWidth = 1
PassNumber. layer. borderColor = UIColor. lightGrayColor (). CGColor
PassNumber. layer. cornerRadius = 5
Self. view. addSubview (PassNumber)
Self. PassNumber = PassNumber
/// Retrieve the password
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 (){
/// Password retrieval prompt
UIAlertView (title: "tip", message: "the new password has been sent to the mobile phone", delegate: nil, cancelButtonTitle: "OK", otherButtonTitles: "cancel"). show ()
}
/**
Click the UI keyboard to quit the first responder
*/
Override func touchesBegan (touches: NSSet, withEvent event: UIEvent ){
Self. QQNumber. resignFirstResponder ()
Self. PassNumber. resignFirstResponder ()
}
}