資源描述:
《【無限互聯(lián)】ios開發(fā)之手勢密碼的實(shí)現(xiàn)舒浪》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在應(yīng)用文檔-天天文庫。
1、【無限互聯(lián)】IOS開發(fā)之手勢密碼的實(shí)現(xiàn)手勢密碼解析代碼結(jié)構(gòu):GesturePasswordView?用以?首?頁布局GesturePasswordButton?用以設(shè)置按鈕效果GesturePasswordController?用以實(shí)現(xiàn)各個功能模塊KeychainItemWrapper?用以保存密碼信息TentacleView?用以設(shè)置輸?入密碼時的線條效果并接受?手勢事件代碼分析:密碼?首?頁布局:GesturePasswordView通過循環(huán)九個button排列出?手勢密碼區(qū),所有的button都存?入buttonArray數(shù)組當(dāng)中,并添加了?一個s
2、tateLabel類?用以顯?示提?示信息[objc]viewplaincopyprint?1.-(id)initWithFrame:(CGRect)frame2.{3.self=[superinitWithFrame:frame];4.//?首?頁密碼視圖布局if(self){5.//Initializationcode6.buttonArray=[[NSMutableArrayalloc]initWithCapacity:0];1.view=[[UIViewalloc]initWithFrame:CGRectMake(frame.size.width
3、/2-160,frame.size.height/2-80,320,320)];2.//創(chuàng)建密碼鍵盤?小視圖0-9for(inti=0;i<9;i++){3.NSIntegerrow=i/3;NSIntegercol=i%3;//ButtonFrame4.//設(shè)置?小視圖Frame5.NSIntegerdistance=320/3;6.NSIntegersize=distance/1.5;7.//每個?小視圖間的空隙8.NSIntegermargin=size/4;9.GesturePasswordButton*gesturePasswordButton
4、=[[GesturePasswordButtonalloc]initWith10.Frame:CGRectMake(col*distance+margin,row*distance,size,size)];[gesturePasswordButtonsetTag:i];11.//把?小視圖添加到View視圖12.[viewaddSubview:gesturePasswordButton];//將視圖屬性存?入數(shù)組13.[buttonArrayaddObject:gesturePasswordButton];}14.frame.origin.y=0;15.
5、[selfaddSubview:view];16.tentacleView=[[TentacleViewalloc]initWithFrame:view.frame];17.//將buttonArray中的View傳給tentacleView中得buttonArray[tentacleViewsetButtonArray:buttonArray];18.//實(shí)現(xiàn)代理19.[tentacleViewsetTouchBeginDelegate:self];[selfaddSubview:tentacleView];20.//布局屏幕第?一個圓形視圖21.im
6、gView=[[UIImageViewalloc]initWithFrame:CGRectMake(frame.size.width/2-35,frame.size.width/2-80,70,70)];22.[imgViewsetBackgroundColor:[UIColorwhiteColor]];23.//設(shè)置圓形視圖24.[imgView.layersetCornerRadius:35];25.[imgView.layersetBorderColor:[UIColorgrayColor].CGColor];[imgView.layersetBo
7、rderWidth:3];26.[selfaddSubview:imgView];27.//創(chuàng)建Label?用以打印?手勢信息1.state=[[UILabelalloc]initWithFrame:CGRectMake(frame.size.width/2-140,frame.size.height/2-120,280,30)];2.[statesetTextAlignment:NSTextAlignmentCenter];[statesetFont:[UIFontsystemFontOfSize:14.f]];[selfaddSubview:stat
8、e];3.forgetButton=[[UIButtonalloc]initWi