IOS_39 _ touch unlock

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.