IOS_39 _ touch unlock
Finally:
Controller: <喎?http: www.bkjia.com kf ware vc " target="_blank" class="keylink"> Vc3Ryb25nPgoKPHByZSBjbGFzcz0 = "brush: java;"> // BeyondViewController. m // 39 _ touch unlock /// Created by beyond on 14-9-17. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "BeyondViewController. h "# import" LockView. h "# import" LockViewDelegate. h "// complies with the Protocol and is used to learn the unlock path drawn by the user on LockView @ interface BeyondViewController () @ End @ implementation BeyondViewController # pragma mark-LockView proxy method // used for obtaining the unlock path drawn by the user on the LockView-(void) lockView :( LockView *) lockView didFinishPath :( NSString *) path {[MBProgressHUD showSuccess: path]; NSLog (@ "get user's gesture path: % @", path) ;}@ end
Custom CircleButton
/// Circle. m // 39 _ touch unlock /// Created by beyond on 14-9-17. // Copyright (c) 2014 com. beyond. all rights reserved. // # import "Circle. h "@ implementation Circle-(id) initWithFrame :( CGRect) frame {self = [super initWithFrame: frame]; if (self) {// custom method, initialize [self setup];} return self;}-(id) initWithCoder :( NSCoder *) aDecoder {if (self = [super initWithCoder: aDecoder]) {// custom method, initialize [self setup];} return self;} // custom method, initialize-(void) setup {// set button unavailable (not clickable) self. userInteractionEnabled = NO; // set the Default background image [self setBackgroundImage: [UIImage imageNamed: @ "gesture_node_normal"] forState: UIControlStateNormal]; // set the selected background image (selected) [self setBackgroundImage: [UIImage imageNamed: @ "gesture_node_highlighted"] forState: UIControlStateSelected];} @ end
Protocols defined by LockView//// LockViewDelegate. h // 39 _ touch to unlock /// Created by beyond on 14-9-17. // Copyright (c) 2014 com. beyond. all rights reserved. // The protocol that the custom LockView proxy must comply with # import
@ Class LockView; @ protocol LockViewDelegate
@ Optional // when the screen lock gesture is drawn, call this method to notify the outside world-(void) lockView :( LockView *) lockView didFinishPath :( NSString *) path; @ end
Core code, custom LockView//// LockView. h // 39 _ touch to unlock /// Created by beyond on 14-9-17. // Copyright (c) 2014 com. beyond. all rights reserved. // # import
@ Protocol LockViewDelegate; @ interface LockView: UIView // proxy for the current controller. The purpose is to notify it @ property (nonatomic, weak) IBOutlet id after the unlock gesture is drawn.
Delegate; @ end
//// LockView. m // 39 _ touch unlock /// Created by beyond on 14-9-17. // Copyright (c) 2014 com. beyond. all rights reserved. // key, core ~~~ # Import "LockView. h "# import" Circle. h "# import" LockViewDelegate. h "@ interface LockView () // array, remember the circle @ property (nonatomic, strong) NSMutableArray * circleArr after all touchMove; // keep your fingers touch the screen, activity point, used to draw the line string @ property (nonatomic, assign) CGPoint activePoint from the center of the last circle to the user's touch point; @ end @ implementation LockView # pragma mark-lazy loading // array, remember all touchMove's circle-(NSMutableArray *) circleArr {if (_ circleArr = nil) {_ circleArr = [NSMutableArray array];} return _ circleArr;} # pragma mark-initialization-(id) initWithFrame :( CGRect) frame {self = [super initWithFrame: frame]; if (self) {// call the custom method, add all the buttons [self addAllCircles];} return self ;}- (id) initWithCoder :( NSCoder *) at a time *) aDecoder {if (self = [super initWithCoder: aDecoder]) {// call a custom method and add all the buttons at a time [self addAllCircles];} return self ;} // call the custom method and add all the buttons at a time-(void) addAllCircles {for (int index = 0; index <9; index ++) {// create a custom button. The tag is bound to the following order: Circle * btn = [Circle buttonWithType: UIButtonTypeCustom]; btn. tag = index; // Add the button [self addSubview: btn] ;}# pragma mark-parent class method // Add a circle for each method, adjust the frame-(void) layoutSubviews of all child controls {// The method of the parent class [super layoutSubviews] must be called first; // traverse all child buttons, re-adjust frame for (int I = 0; I
Storyboard