您的位置:首页 > 移动开发 > Swift

swift输入验证码提示框

2016-04-19 15:31 513 查看
//

// XCSurePayV.swift

// zjfae

//

// Created by apple on 16/4/19.

// Copyright © 2016年 onight. All rights reserved.

//

import UIKit

class XCSurePayV:
UIView {

// var showView : UIView?

override init(frame:
CGRect) {

super.init(frame: frame)

self.addSubview(bgView)

self.addSubview(showView)

showView.addSubview(payLab)

showView.addSubview(tishiTitle)

showView.addSubview(codeTF)

showView.addSubview(cancelBtn)

showView.addSubview(sureBtn)

showView.addSubview(line1)

showView.addSubview(line2)

showView.addSubview(line3)

bgView.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsMake(0,
0, 0,
0))

showView.autoPinEdge(.Left, toEdge: .Left, ofView:
self, withOffset:
20)

showView.autoPinEdge(.Right, toEdge: .Right, ofView:
self, withOffset: -20)

showView.autoAlignAxisToSuperviewAxis(.Horizontal)

showView.autoSetDimension(.Height, toSize:
220)

payLab.autoPinEdgesToSuperviewEdgesWithInsets(UIEdgeInsetsMake(0,
0, 0,
0), excludingEdge: .Bottom)

payLab.autoSetDimension(.Height, toSize:
44)

line1.autoPinEdge(.Left, toEdge: .Left, ofView:
showView, withOffset:
0)

line1.autoPinEdge(.Top, toEdge: .Bottom, ofView:
payLab, withOffset:
0)

line1.autoPinEdge(.Right, toEdge: .Right, ofView:
payLab, withOffset:
0)

line1.autoSetDimension(.Height, toSize:
1)

tishiTitle.autoPinEdge(.Left, toEdge: .Left, ofView:
showView, withOffset:
40)

tishiTitle.autoPinEdge(.Top, toEdge: .Bottom, ofView:
line1, withOffset:
5)

tishiTitle.autoPinEdge(.Right, toEdge: .Right, ofView:
showView, withOffset: -40)

tishiTitle.autoSetDimension(.Height, toSize:
54)

codeTF.autoSetDimension(.Height, toSize:
34)

codeTF.autoPinEdge(.Left, toEdge: .Left, ofView:
showView, withOffset:
30)

codeTF.autoPinEdge(.Top, toEdge: .Bottom, ofView:
tishiTitle, withOffset:
10)

codeTF.autoPinEdge(.Right, toEdge: .Right, ofView:
showView, withOffset: -30)

cancelBtn.autoPinEdge(.Left, toEdge: .Left, ofView:
showView, withOffset:
0)

cancelBtn.autoPinEdge(.Bottom, toEdge: .Bottom, ofView:
showView, withOffset:
0)

cancelBtn.autoSetDimension(.Height, toSize:
44)

cancelBtn.autoSetDimension(.Width, toSize: (KEY_SCREEN_SIZE.width-40)/2-1)

line2.autoPinEdge(.Left, toEdge: .Right, ofView:
cancelBtn, withOffset:
0)

line2.autoPinEdge(.Bottom, toEdge: .Bottom, ofView:
showView, withOffset:
0)

line2.autoSetDimension(.Height, toSize:
44)

line2.autoSetDimension(.Width, toSize:
1)

sureBtn.autoPinEdge(.Left, toEdge: .Right, ofView:
line2, withOffset:
0)

sureBtn.autoPinEdge(.Right, toEdge: .Right, ofView:
showView, withOffset:
0)

sureBtn.autoPinEdge(.Bottom, toEdge: .Bottom, ofView:
showView, withOffset:
0)

sureBtn.autoSetDimension(.Height, toSize:
44)

line3.autoSetDimension(.Height, toSize:
1)

line3.autoPinEdge(.Left, toEdge: .Left, ofView:
showView, withOffset:
0)

line3.autoPinEdge(.Right, toEdge: .Right, ofView:
showView, withOffset:
0)

line3.autoPinEdge(.Bottom, toEdge: .Top, ofView:
sureBtn, withOffset:
0)

}

required init?(coder aDecoder:
NSCoder) {

fatalError("init(coder:) has not been implemented")

}

private lazy
var bgView : UIView = {

let bgView =
UIView.newAutoLayoutView()

bgView.alpha =
0.3

bgView.backgroundColor =
UIColor.blackColor()

return bgView

}()

//
提示框白色View

private lazy
var showView:UIView = {

let showView =
UIView.newAutoLayoutView()

showView.backgroundColor =
UIColor.whiteColor()

showView.layer.cornerRadius =
5

showView.layer.masksToBounds =
true

return showView

}()

//
标题

private lazy
var payLab : UILabel = {

let payLab =
UILabel.newAutoLayoutView()

payLab.text =
"付款确认"

payLab.textAlignment =
NSTextAlignment.Center

return payLab

}()

//
提示信息

private lazy
var tishiTitle:UILabel = {

let tishiTitle =
UILabel.newAutoLayoutView()

tishiTitle.numberOfLines=0;

tishiTitle.text="本次交易需要短信确认,验证码已经发送至您的手机158****3654"

tishiTitle.textAlignment=NSTextAlignment.Center

tishiTitle.font =
UIFont.systemFontOfSize(15)

tishiTitle.textColor =
UIColor.grayColor()

return tishiTitle

}()

//
输入验证码

private lazy
var codeTF:UITextField = {

let codeTF =
UITextField.newAutoLayoutView()

codeTF.placeholder =
" 请输入密码"

let codebtn =
UIButton(frame:CGRectMake(0,0,70,34))

codebtn.setTitle("获取", forState:
UIControlState.Normal)

codebtn.bk_addEventHandler({ (a)
in

XCTools().sendCode(codebtn,color:KEY_COLOR_NAV)

}, forControlEvents: UIControlEvents.TouchUpInside)

codebtn.backgroundColor =
KEY_COLOR_NAV

codeTF.layer.borderColor=KEY_COLOR_NAV.CGColor

codeTF.layer.borderWidth =
1.0

codebtn.backgroundColor =
KEY_COLOR_NAV

codeTF.rightView = codebtn

codeTF.rightViewMode =
UITextFieldViewMode.Always

return codeTF

}()

private lazy
var line1 : UILabel = {

let line1 =
UILabel.newAutoLayoutView()

line1.backgroundColor =
UIColor.lightGrayColor()

return line1

}()

private lazy
var line2 : UILabel = {

let line1 =
UILabel.newAutoLayoutView()

line1.backgroundColor =
UIColor.lightGrayColor()

return line1

}()

private lazy
var line3 : UILabel = {

let line1 =
UILabel.newAutoLayoutView()

line1.backgroundColor =
UIColor.lightGrayColor()

return line1

}()

private lazy
var cancelBtn:UIButton = {

let cancelBtn =
UIButton.newAutoLayoutView()

cancelBtn.setTitle("取消", forState:
UIControlState.Normal)

cancelBtn.setTitleColor(UIColor.blackColor(), forState:
UIControlState.Normal)

cancelBtn.backgroundColor =
UIColor.whiteColor()

cancelBtn.addTarget(self, action:
#selector(sureBtnClick), forControlEvents:
UIControlEvents.TouchUpInside)

return cancelBtn

}()

private lazy
var sureBtn:UIButton = {

let sureBtn =
UIButton.newAutoLayoutView()

sureBtn.setTitle("确定", forState:
UIControlState.Normal)

sureBtn.setTitleColor(KEY_COLOR_NAV, forState:
UIControlState.Normal)

sureBtn.backgroundColor =
UIColor.whiteColor()

sureBtn.addTarget(self, action:
#selector(sureBtnClick), forControlEvents:
UIControlEvents.TouchUpInside)

return sureBtn

}()

func sureBtnClick() ->
Void {

self.removeFromSuperview()

}

/*

// Only override drawRect: if you perform custom drawing.

// An empty implementation adversely affects performance during animation.

override func drawRect(rect: CGRect) {

// Drawing code

}

*/

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: