支付密码输入
来源:互联网 发布:怎么申请淘宝达人 编辑:程序博客网 时间:2024/05/01 17:16
.h文件
#import <UIKit/UIKit.h>
@protocol payPwsViewDelegate <NSObject>
- (void)payPwsViewDelegate;
@end
@interface PayPwsView : UIView{
}
@property(nonatomic,strong)id <payPwsViewDelegate> delegate;
@end
.m文件
//
// PayPwsView.m
// GWhome
//
// Created by 陈万里 on 15/11/27.
// Copyright © 2015年 chenwanli. All rights reserved.
//
#import "PayPwsView.h"
#define RGB_A(R,G,B,A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
// 获取屏幕高度
#define kDeviceHeight [UIScreen mainScreen].bounds.size.height
// 获取屏幕宽度
#define kDeviceWidth [UIScreen mainScreen].bounds.size.width
#define FONTNAME(font,name) [UIFont fontWithName:name size:font];
@implementation PayPwsView
- (id)initWithFrame:(CGRect)frame{
self = [superinitWithFrame:frame];
if (self) {
self.backgroundColor =RGB_A(0,0, 0,0.5);
UIView *bgView =[[UIViewalloc]initWithFrame:CGRectMake((kDeviceWidth -280) / 2,kDeviceHeight - 400,280, 150)];
bgView.layer.cornerRadius =5;
bgView.layer.masksToBounds =YES;
bgView.backgroundColor = [UIColorwhiteColor];
[selfaddSubview:bgView];
UILabel *pwsLabel = [[UILabelalloc]initWithFrame:CGRectMake(0,0, bgView.frame.size.width,40)];
pwsLabel.textAlignment =1;
pwsLabel.font =FONTNAME(18,@"Helvetica-Bold");
pwsLabel.text =@"请输入支付密码";
[bgView addSubview:pwsLabel];
// 分割线
UIImageView *separatorImg = [[UIImageViewalloc]initWithFrame:CGRectMake(0,39, bgView.frame.size.width,1)];
separatorImg.backgroundColor = [UIColorredColor];
[bgView addSubview:separatorImg];
float initialX = (bgView.frame.size.width - 40 * 6) /2;
for (int i =0; i < 6; i++) {
UITextField *pwsField = [[UITextFieldalloc]initWithFrame:CGRectMake(initialX + i *40, 75,40, 40)];
pwsField.textAlignment =1;
pwsField.tag = i +100;
pwsField.keyboardType =UIKeyboardTypeNumberPad;
pwsField.layer.borderWidth =0.5;
pwsField.layer.borderColor = [UIColorblackColor].CGColor;
pwsField.secureTextEntry =YES;
pwsField.userInteractionEnabled =NO;
[bgView addSubview:pwsField];
}
UIButton *pwsBut = [UIButtonbuttonWithType:UIButtonTypeCustom];
pwsBut.frame =CGRectMake(initialX, 100,35 * 6,35);
[pwsBut addTarget:selfaction:@selector(pwsBut:)forControlEvents:UIControlEventTouchUpInside];
[bgView addSubview:pwsBut];
UITextField *bigPwsField = [[UITextFieldalloc]initWithFrame:CGRectMake(0,0, 35,35)];
bigPwsField.hidden =YES;
bigPwsField.textAlignment =1;
bigPwsField.tag =1000;
bigPwsField.keyboardType =UIKeyboardTypeNumberPad;
[bigPwsField addTarget:selfaction:@selector(pwsField:)forControlEvents:UIControlEventEditingChanged];
[bgView addSubview:bigPwsField];
}
returnself;
}
- (void)pwsBut:(UIButton *)sender{
UITextField *pwsField = (UITextField *)[selfviewWithTag:1000];
if (sender ==nil) {
pwsField.text =@"";
}
[selfdistributionPws];
[pwsField becomeFirstResponder];
}
- (void)distributionPws{
UITextField *bigPwsField = (UITextField *)[selfviewWithTag:1000];
for (int i =0; i < 6; i++) {
if (i < bigPwsField.text.length) {
UITextField *pwsField = (UITextField *)[selfviewWithTag:100 + i];
pwsField.text = [bigPwsField.textsubstringWithRange:NSMakeRange(i,1)];
}else{
UITextField *pwsField = (UITextField *)[selfviewWithTag:100 + i];
pwsField.text =@"";
}
}
}
- (void)pwsField:(UITextField *)sender{
if (sender.text.length <7) {
[selfdistributionPws];
if (sender.text.length ==6) {
[selfkenEnd];
[self.delegatepayPwsViewDelegate];
}
}else{
sender.text = [sender.textsubstringWithRange:NSMakeRange(0,sender.text.length - 1)];
}
}
- (void)setFrame:(CGRect)frame{
[supersetFrame:frame];
if (frame.origin.y <1) {
[selfpwsBut:nil];
}
}
- (void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
[selfkenEnd];
}
- (void)kenEnd{
[self.superviewendEditing:YES];
[UIViewanimateWithDuration:0.5animations:^{
self.frame =CGRectMake(0,kDeviceHeight,kDeviceWidth,kDeviceHeight);
}];
}
@end
- 支付密码输入
- 仿支付宝支付密码输入框
- Android 支付宝支付密码输入界面
- 仿微信支付宝输入支付密码
- 仿支付宝支付 密码输入
- THML输入支付密码框
- Android支付密码输入框
- 支付的密码输入框
- 仿微信支付密码输入框
- js模拟支付密码输入
- 自定义输入支付密码框
- 实现简单输入支付密码的输入
- android仿微信修改支付密码输入框
- 仿微信输入支付密码的弹窗
- android 仿美团支付的密码输入页
- iOS---防支付宝密码输入样式
- Android 仿微信支付密码输入框
- 类似解锁或者支付密码输入框
- Linux常用命令整理
- HTML5简的常用元素与属性(二): html5新增的通用属性
- Java编码规范—约定也要配置
- MyBatis概述及学习资料整理
- MyBatis代码自动生成
- 支付密码输入
- MyBatis与Spring集成
- 深入理解控件(ViewRoot)系统(节选)
- 技术经理角色的几点思考
- Git解惑
- 【iOS9】真机测试添加证书
- Android 蓝牙BLE (蓝牙成长之路)4
- 性能测试集合
- 使用设计模式改善程序结构(二)