码迷,mamicode.com
首页 > 移动开发 > 详细

ios模仿qq登陆界面

时间:2015-06-26 16:22:40      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:swift   ios   界面   


给大家推荐两个学习的地址:

极客学院的视频:http://www.jikexueyuan.com/path/ios/

一个博客:http://blog.csdn.net/lizhongfu2013/article/details/29210015

技术分享

主要想要实现一个模仿的登陆界面

代码:

//
//  LoginViewController.swift
//  IBM_LOGIN
//
//  Created by dcintern on 6/26/15.
//  Copyright (c) 2015 dcintern. All rights reserved.
//

//import Foundation

import UIKit

class LoginViewController: UIViewController
{

    


/// 定义属性
var QQNumber = UITextField()
var PassNumber = UITextField()


override func viewDidLoad() {
    
    self.view.backgroundColor = UIColor.whiteColor()
    super.viewDidLoad()
    
    // 添加头图片
    [self .addAllSubViews()];
}

// 添加所有子控件
func addAllSubViews(){
    
    /// 平铺背景
    var headImage = UIImageView(frame: CGRectMake(0,0, 400, 800))
    headImage.image =  UIImage(named:"123.jpeg")
    self.view.addSubview(headImage)
    
    /// QQ号输入提示,暂时没有用到
    var phoneText = UILabel(frame: CGRectMake(30, 240, UIScreen.mainScreen().bounds.size.width-60, 30))
    phoneText.text = ""
    self.view.addSubview(phoneText)
    
    /// QQ号输入框
    var QQNumber = UITextField(frame: CGRectMake(30, 150, UIScreen.mainScreen().bounds.size.width-60, 30))
    QQNumber.placeholder = " username"
    QQNumber.layer.borderWidth = 2
    QQNumber.layer.borderColor = UIColor.lightGrayColor().CGColor
    QQNumber.layer.cornerRadius = 5
    QQNumber.keyboardType = UIKeyboardType.NumberPad
    self.view.addSubview(QQNumber)
    self.QQNumber = QQNumber
    
    /// 密码输入提示,暂时没用到
    var passText = UILabel(frame: CGRectMake(30, 300, UIScreen.mainScreen().bounds.size.width-60, 30))
    passText.text = ""
    self.view.addSubview(passText)
    
    /// 密码输入框
    var PassNumber = UITextField(frame: CGRectMake(30, 200, UIScreen.mainScreen().bounds.size.width-60, 30))
    PassNumber.placeholder = " password"
    PassNumber.layer.borderWidth = 2
    PassNumber.layer.borderColor = UIColor.lightGrayColor().CGColor
    PassNumber.layer.cornerRadius = 5
    self.view.addSubview(PassNumber)
    self.PassNumber = PassNumber
    
    /// 密码找回
    var button = UIButton(frame: CGRectMake(200, 360, 120, 30))
    UIButton.buttonWithType(UIButtonType.Custom)
    button.setTitle("忘记密码", forState: UIControlState.Normal)
    button.setTitleColor(UIColor.lightGrayColor(), forState: UIControlState.Normal)
    self.view.addSubview(button)
    button.addTarget(self, action: "onClick", forControlEvents: UIControlEvents.TouchUpInside)
    
}

/// 密码找回方法实现
func onClick()
{
    
    ///找回密码提示
    UIAlertView(title: "温馨提示", message: "新密码已发送至手机上", delegate: nil, cancelButtonTitle: "确定", otherButtonTitles: "取消").show()
}
/**
点击界面键盘辞去第一响应者
*/
override func touchesBegan(touches: NSSet, withEvent event: UIEvent)
{
    
    self.QQNumber.resignFirstResponder()
    self.PassNumber.resignFirstResponder()
}

}



ios模仿qq登陆界面

标签:swift   ios   界面   

原文地址:http://blog.csdn.net/wangyaninglm/article/details/46650157

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!