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
}
*/
}
// 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
}
*/
}
相关文章推荐
- swift分装的倒计时按钮
- Swift UIFont 传入字体name和size问题
- Swift 下debug状态打印log
- Swift笔记:方法
- 自定义presentViewController的转场动画(Swift)
- Swift PageControl
- Swift -- 2.基本数据类型
- Swift UIDatePikcer
- swift-元组的基本用法
- Apple Swift编程语言入门教程
- swift和oc混编
- 趋势!SWIFT必定会被区块链技术取…
- SWIFT:必须承认区块链在金融行业…
- Swift提出“区块链路线图”,谋求突…
- 消息人士称,Google考虑将Swift作为安卓的主要编程语言
- swift 属性的几个写法
- 更简单地进行Auto Layout--SnapKit 支持swift
- Swift学习笔记(三)
- Swift 闭包(Closures)传值
- swift(02)基础学习