欢迎来到天天文库
浏览记录
ID:15281107
大小:193.79 KB
页数:10页
时间:2018-08-02
《【无限互联】ios开发之手势密码的实现》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、手势密码解析代码结构:GesturePasswordView⽤用以⾸首⻚页布局GesturePasswordButton⽤用以设置按钮效果GesturePasswordController⽤用以实现各个功能模块KeychainItemWrapper⽤用以保存密码信息TentacleView⽤用以设置输⼊入密码时的线条效果并接受⼿手势事件代码分析:密码⾸首⻚页布局:GesturePasswordView通过循环九个button排列出⼿手势密码区,所有的button都存⼊入buttonArray数组当中,并添加了⼀一个stateL
2、abel类⽤用以显⽰示提⽰示信息[objc] viewplaincopy1.- (id)initWithFrame:(CGRect)frame 2.{ 3.self = [super initWithFrame:frame]; 4.//⾸首⻚页密码视图布局if (self) { 5.// Initialization code 6.buttonArray = [[NSMutableArray alloc]initWithCapacity:0]; 7.view = [[UIView alloc]initWithFra
3、me:CGRectMake(frame.size.width/2-160, frame.size.height/2-80, 320, 320)]; 8.//创建密码键盘⼩小视图 0-9for (int i=0; i<9; i++) { 9.NSInteger row = i/3;NSInteger col = i%3;// Button Frame 10.//设置⼩小视图Frame 11.NSInteger distance = 320/3; 1.NSInteger size = distance/1.5; 2./
4、/每个⼩小视图间的空隙 3.NSInteger margin = size/4; 4.GesturePasswordButton * gesturePasswordButton = [[GesturePasswordButton alloc]initWith 5.Frame:CGRectMake(col*distance+margin, row*distance, size, size)];[gesturePasswordButton setTag:i]; 6.//把⼩小视图添加到View视图 7.[view add
5、Subview:gesturePasswordButton];//将视图属性存⼊入数组 8.[buttonArray addObject:gesturePasswordButton];} 9.frame.origin.y=0; 10.[self addSubview:view]; 11.tentacleView = [[TentacleView alloc]initWithFrame:view.frame]; 12.//将buttonArray中的View 传给 tentacleView 中得buttonArray[
6、tentacleView setButtonArray:buttonArray]; 13.//实现代理 14.[tentacleView setTouchBeginDelegate:self];[self addSubview:tentacleView]; 15.//布局屏幕第⼀一个圆形视图 16.imgView = [[UIImageView alloc]initWithFrame:CGRectMake(frame.size.width/2-35, frame.size.width/2-80, 70, 70)];
7、17.[imgView setBackgroundColor:[UIColor whiteColor]]; 18.//设置圆形视图 19.[imgView.layer setCornerRadius:35]; 20.[imgView.layer setBorderColor:[UIColor grayColor].CGColor];[imgView.layer setBorderWidth:3]; 21.[self addSubview:imgView]; 22.//创建Label ⽤用以打印⼿手势信息 23.st
8、ate = [[UILabel alloc]initWithFrame:CGRectMake(frame.size.width/2-140, frame.size.height/2-120, 280, 30)]; 24.[state setTextAlignment:NST
此文档下载收益归作者所有