iOS圖案鎖,支持動畫、圖片、繪圖

最近忙着搭建一個聊天用的框架,過幾天應該會整理寫出來吧,原理不難,可是實現後會省不少事。很久沒寫博客,週末心血來潮寫了個圖案鎖,這東西沒什麼技術含量,網上一堆,此次這個圖案鎖順便聯繫了怎麼打包使用.a .bundle框架

注:支持動畫、圖片作觸摸點,另外,打包成.a的資源包含了圖片,比較大,想自定義的童鞋,能夠使用未打包的,而後本身定義資源,使用顏色的,會按照默認樣式繪圖,很差意思,如今不支持改變樣式,只能改變顏色,不過圖片能夠彌補這個缺陷。動畫

先上超連接: atom

    普通版:PLView.zipspa

   .a含資源版:PatternLockView.a.zipcode

使用方法裏面有;blog

下面簡單的介紹下圖片

 1 #import "ViewController.h"
 2 #import "PatternLockView.h"//頭文件
 3 
 4 @interface ViewController () <PatternlockViewDelegate>//協議
 5 @property (nonatomic,strong) PatternLockView * pv; //view
 6 @end
 7 
 8 @implementation ViewController
 9 
10 - (void)viewDidLoad {
11     [super viewDidLoad];
12     // Do any additional setup after loading the view, typically from a nib.
13     _pv = [[PatternLockView alloc]initWithFrame:self.view.frame];//建議採用initWithFrame初始化
14     
15     [_pv setFillWay:PLFillWayAnimation andFillArray:nil];//設置填充方式,資源填nil則須要引入我以前製做的圖片資源
16     
17     [_pv setPointsSize:CGSizeMake(3, 3)];//設置點的個數,這裏是3*3
18     
19     [_pv setPointRadius:50];//設置點的半徑
20     
21     _pv.delegate = self;
22     
23     [_pv startDraw];//必定要完成設置再調用該方法,
24     
25     [self.view addSubview:_pv];
26 //    [_pv clearDraw]  //恢復默認樣式。
27 }
28 //協議方法
29 - (void)PatternlockView:(PatternLockView*)patternlockView didTouchPointAtIndex:(NSInteger)index andCountOfTouchPoint:(NSInteger)count
30 {
31     NSLog(@"當前選擇的是:%ld ,當前供選擇了%ld個點。",(long)index,(long)count);
32 }
33 //協議方法
34 - (void)PatternlockView:(PatternLockView*)patternlockView didEndTouchMoveWithIndexs:(NSArray<NSNumber*>*)indexs
35 {
36     NSLog(@"共選擇%@",indexs);
37 }
38 //協議方法
39 - (void)PatternlockView:(PatternLockView*)patternlockView didEndTouchMoveWithString:(NSString*)string
40 {
41     NSLog(@"選擇結束的字符串是:%@",string);
42     
43     NSLog(@"將樣式設置成成功樣式!");
44     [_pv setStyleTo:PatternLockStyleSuccess];
45 }

使用不是很麻煩,可是記得在  startDraw 以前完成相關設置,設置都有默認值。ip

差幾張截圖:資源

相關文章
相關標籤/搜索