標籤:
最近忙著搭建一個聊天用的架構,過幾天應該會整理寫出來吧,原理不難,但是實現後會省很多事。好久沒寫部落格,周末心血來潮寫了個圖案鎖,這東西沒什麼技術含量,網上一堆,這次這個圖案鎖順便聯絡了怎麼打包使用.a .bundle
註:支援動畫、圖片做觸摸點,另外,打包成.a的資源套件含了圖片,比較大,想自訂的童鞋,可以使用未打包的,然後自己定義資源,使用顏色的,會按照預設樣式繪圖,不好意思,現在不支援改變樣式,只能改變顏色,不過圖片可以彌補這個缺陷。
先上超連結:
普通版:PLView.zip
.a含資源版:PatternLockView.a.zip
使用方法裡面有;
下面簡單的介紹下
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*318 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)count30 {31 NSLog(@"當前選擇的是:%ld ,當前供選擇了%ld個點。",(long)index,(long)count);32 }33 //協議方法34 - (void)PatternlockView:(PatternLockView*)patternlockView didEndTouchMoveWithIndexs:(NSArray<NSNumber*>*)indexs35 {36 NSLog(@"共選擇%@",indexs);37 }38 //協議方法39 - (void)PatternlockView:(PatternLockView*)patternlockView didEndTouchMoveWithString:(NSString*)string40 {41 NSLog(@"選擇結束的字串是:%@",string);42 43 NSLog(@"將樣式設定成成功樣式!");44 [_pv setStyleTo:PatternLockStyleSuccess];45 }
使用不是很麻煩,但是記得在 startDraw 之前完成相關設定,設定都有預設值。
差幾張:
iOS圖案鎖,支援動畫、圖片、繪圖