防支付宝支付界面

#define kDotSize  CGSizeMake(10, 10) //密码点的大小#define kDotCount 6//密码个数#define k_Field_Height 45  //每一个输入框的高度

@interface ViewController6 (){

UILabel* infoLab ;//提示信息

UIView* scrView;

UITextField* textField1;//输入框

UIView* topView;//顶部试图

double duration;

UIView *animateView;//加载动画

}

@property (nonatomic, strong) NSMutableArray *dotArray; //用于存放黑色的点点

@property (nonatomic, strong) FLAnimatedImageView *imageView1;

@end

@implementation ViewController6

- (void)viewWillAppear:(BOOL)animated{

[super viewWillAppear:animated];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillChangeFrame:) name:UIKeyboardWillChangeFrameNotification object:nil];

}

- (void)dealloc

{

[[NSNotificationCenter defaultCenter] removeObserver:self];

}

#pragma mark - 监听方法

/**

* 键盘的frame发生改变时调用(显示、隐藏等)

*/

- (void)keyboardWillChangeFrame:(NSNotification *)notification

{

//    if (self.picking) return;

/**

notification.userInfo = @{

// 键盘弹出\隐藏后的frame

UIKeyboardFrameEndUserInfoKey = NSRect: {{0, 352}, {320, 216}},

// 键盘弹出\隐藏所耗费的时间

UIKeyboardAnimationDurationUserInfoKey = 0.25,

// 键盘弹出\隐藏动画的执行节奏(先快后慢,匀速)

UIKeyboardAnimationCurveUserInfoKey = 7

}

*/

NSDictionary *userInfo = notification.userInfo;

// 动画的持续时间

duration = [userInfo[UIKeyboardAnimationDurationUserInfoKey] doubleValue];

// 键盘的frame

CGRect keyboardF = [userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];

// 执行动画

[UIView animateWithDuration:duration animations:^{

//        _blackBgView.alpha = 0.410;

// 工具条的Y值 == 键盘的Y值 - 工具条的高度

if (keyboardF.origin.y > self.view.height) { // 键盘的Y值已经远远超过了控制器view的高度

scrView.hidden = YES;

} else {

scrView.top  = keyboardF.origin.y - scrView.height;

scrView.hidden = NO;

topView.height = self.view.height- scrView.height-keyboardF.size.height;

}

} completion:^(BOOL finished) {

}];

}

- (void)viewDidLoad {

[super viewDidLoad];

self.title = @"交易信息";

[self initInterface];

[self initPwdTextField];

[self initImage];

}

- (void)initInterface{

self.view.backgroundColor = [UIColor whiteColor];

UIButton* but = [UIButton buttonWithType:UIButtonTypeCustom];

[self.view addSubview:but];

but.frame = CGRectMake(100, 100, 50, 50);

but.backgroundColor = [UIColor redColor];

[but addTarget:self action:@selector(didBut) forControlEvents:UIControlEventTouchUpInside];

scrView = [[UIView alloc]init];

[self.view addSubview:scrView];

scrView.backgroundColor = [UIColor colorWithHex:0xFFFFFF];

scrView.hidden = YES;

scrView.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height/3.0, [UIScreen mainScreen].bounds.size.width, 193);

topView = [[UIView alloc]init];

[self.view addSubview:topView];

topView.backgroundColor = [[UIColor colorWithHex:0xC5C5C5]colorWithAlphaComponent:0.5];

topView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 0);

topView.hidden = YES;

UITapGestureRecognizer* tapGesRec = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(didTopView)];

[topView addGestureRecognizer:tapGesRec];

infoLab = [[UILabel alloc]init];

[scrView addSubview:infoLab];

infoLab.frame = CGRectMake(50, 5, [UIScreen mainScreen].bounds.size.width-100, 20);

infoLab.textAlignment = NSTextAlignmentCenter;

infoLab.textColor = [UIColor colorWithHex:0x333333];

infoLab.text = @"输入6位交易密码";

infoLab.font = [UIFont systemFontOfSize:15.0];

textField1 = [[UITextField alloc]init];

[scrView addSubview:textField1];

textField1.delegate = self;

textField1.secureTextEntry =YES;

textField1.backgroundColor = [UIColor whiteColor];

textField1.frame = CGRectMake(53, infoLab.bottom+8, scrView.width-106, k_Field_Height);

textField1.keyboardType = UIKeyboardTypeNumberPad;

[textField1 addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];

//输入的文字颜色为白色

textField1.textColor = [UIColor whiteColor];

//输入框光标的颜色为白色

textField1.tintColor = [UIColor whiteColor];

textField1.autocapitalizationType = UITextAutocapitalizationTypeNone;

textField1.layer.borderColor = [[UIColor lightGrayColor] CGColor];

textField1.layer.borderWidth = 1;

textField1.layer.cornerRadius = 5;

textField1.secureTextEntry = YES;

textField1.font = [UIFont systemFontOfSize:3];

UIButton* butForget = [UIButton buttonWithType:UIButtonTypeCustom];

[scrView addSubview:butForget];

butForget.frame = CGRectMake(50, textField1.bottom+25,  [UIScreen mainScreen].bounds.size.width-100, 20);

[butForget setTitle:@"忘记密码" forState:UIControlStateNormal];

[butForget setTitleColor:[UIColor colorWithHex:0x67B8F3] forState:UIControlStateNormal];

[butForget addTarget:self action:@selector(didButForget) forControlEvents:UIControlEventTouchUpInside];

butForget.titleLabel.font = [UIFont systemFontOfSize:15.0];

butForget.contentVerticalAlignment = NSTextAlignmentCenter;

animateView = [[UIView alloc]init];

[self.view addSubview:animateView];

animateView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);

animateView.hidden = YES;

animateView.backgroundColor = [[UIColor colorWithHex:0xCCCCCC]colorWithAlphaComponent:0.5];

UIView* loadAnimateView = [[UIView alloc]init];

[animateView addSubview:loadAnimateView];

loadAnimateView.backgroundColor = [UIColor whiteColor];

loadAnimateView.frame = CGRectMake(0, 222, [UIScreen mainScreen].bounds.size.width,[UIScreen mainScreen].bounds.size.height-222 );

self.imageView1 = [[FLAnimatedImageView alloc]init];

NSURL *url1 = [[NSBundle mainBundle] URLForResource:@"123" withExtension:@"gif"];

NSData *data1 = [NSData dataWithContentsOfURL:url1];

FLAnimatedImage *animatedImage1 = [FLAnimatedImage animatedImageWithGIFData:data1];

self.imageView1.animatedImage = animatedImage1;

self.imageView1.frame = CGRectMake(([UIScreen mainScreen].bounds.size.width-100)/2.0, 158, 100, 100);

[loadAnimateView addSubview:self.imageView1];

UILabel* animateLab = [[UILabel alloc]init];

[loadAnimateView addSubview:animateLab];

animateLab.frame = CGRectMake(30, self.imageView1.bottom, [UIScreen mainScreen].bounds.size.width-60, 20);

animateLab.textAlignment = NSTextAlignmentCenter;

animateLab.textColor = [UIColor colorWithHex:0x7D7D7D];

animateLab.font = [UIFont systemFontOfSize:15];

animateLab.text = @"提交成功,请稍候...";

}

- (void)didTopView{

[textField1 resignFirstResponder];

topView.hidden = YES;

scrView.hidden = YES;

}

- (void)didButForget{

NSLog(@"忘记密码");

infoLab.text = [NSString stringWithFormat:@"密码错误,还剩%@次机会",@(2)];

infoLab.textColor = [UIColor colorWithHex:0xF61B1C];

}

- (void)didBut{

NSLog(@"是否输入密码");

[textField1 becomeFirstResponder];

scrView.hidden = NO;

topView.hidden = NO;

}

#pragma mark----禁止复制粘贴

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender

{

return NO;

}

- (void)initPwdTextField

{

//每个密码输入框的宽度

CGFloat width = ([UIScreen mainScreen].bounds.size.width - 106) / kDotCount;

//生成分割线

for (int i = 0; i < kDotCount - 1; i++) {

UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0 + (i + 1) * width, 0, 1, k_Field_Height)];

lineView.backgroundColor = [UIColor colorWithHex:0xCCCCCC];

[textField1 addSubview:lineView];

}

self.dotArray = [[NSMutableArray alloc] init];

//生成中间的点

for (int i = 0; i < kDotCount; i++) {

UIView *dotView = [[UIView alloc] initWithFrame:CGRectMake(0 + (width - kDotCount) / 2 + i * width, 0+ (k_Field_Height - kDotSize.height) / 2, kDotSize.width, kDotSize.height)];

dotView.backgroundColor = [UIColor colorWithHex:0x4D4D4D];

dotView.layer.cornerRadius = kDotSize.width / 2.0f;

dotView.clipsToBounds = YES;

dotView.hidden = YES; //先隐藏

[textField1 addSubview:dotView];

//把创建的黑色点加入到数组中

[self.dotArray addObject:dotView];

}

}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string

{

NSLog(@"变化%@", string);

if([string isEqualToString:@"\n"]) {

//按回车关闭键盘

[textField resignFirstResponder];

return NO;

} else if(string.length == 0) {

//判断是不是删除键

return YES;

}

else if(textField.text.length >= kDotCount) {

//输入的字符个数大于6,则无法继续输入,返回NO表示禁止输入

NSLog(@"输入的字符个数大于6,忽略输入");

return NO;

} else {

return YES;

}

}

/**

*  清除密码

*/

- (void)clearUpPassword

{

textField1.text = @"";

[self textFieldDidChange:textField1];

}

/**

*  重置显示的点

*/

- (void)textFieldDidChange:(UITextField *)textField

{

NSLog(@"%@", textField.text);

for (UIView *dotView in self.dotArray) {

dotView.hidden = YES;

}

for (int i = 0; i < textField.text.length; i++) {

((UIView *)[self.dotArray objectAtIndex:i]).hidden = NO;

}

if (textField.text.length == kDotCount) {

NSLog(@"输入完毕");

NSLog(@"%@",textField1.text);

[textField1 resignFirstResponder];

topView.hidden = YES;

scrView.hidden = YES;

animateView.hidden = NO;

}

}

- (void)initImage{

//    UIImage *animatedImage = [UIImage animatedImageWithImages:images duration:duration];

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 202,723评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,080评论 2 379
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 149,604评论 0 335
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,440评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,431评论 5 364
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,499评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,893评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,541评论 0 256
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,751评论 1 296
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,547评论 2 319
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,619评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,320评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,890评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,896评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,137评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,796评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,335评论 2 342

推荐阅读更多精彩内容

  • *7月8日上午 N:Block :跟一个函数块差不多,会对里面所有的内容的引用计数+1,想要解决就用__block...
    炙冰阅读 2,468评论 1 14
  • VLC的集成和使用 VLC介绍 VLC Media Player (VideoLAN) 为 Windows、Lin...
    Pocket阅读 19,447评论 75 66
  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌。在这里你可以看...
    F麦子阅读 5,089评论 5 13
  • 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥ios动画全貌。在这里你可以看...
    每天刷两次牙阅读 8,455评论 6 30
  • 我喜欢读甜蜜的文字,讨厌相爱相杀的过程,所以习惯每次看什么,都摒弃那些虐心的情节和发展。所以很多我笔下的故事,也许...
    酒衫霖阅读 550评论 0 0