DBGuestureLock.h 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // DBGuestureLock.h
  3. // DBGuestureLock
  4. //
  5. // Created by DeBao.Wu on 2/27/16.
  6. // Email: i36.lib@gmail.com QQ: 754753371
  7. // Copyright © 2016 http://i36.Me/. All rights reserved.
  8. // Github地址: https://github.com/i36lib/DBGuestureLock/
  9. #import <UIKit/UIKit.h>
  10. #define DBFirstTimeSetupPassword @"Me_i36_DBGuestureLock_DBFirstSetupPswd"
  11. @class DBGuestureLock;
  12. // Button state
  13. typedef NS_ENUM(NSInteger, DBButtonState) {
  14. DBButtonStateNormal = 0,
  15. DBButtonStateSelected,
  16. DBButtonStateIncorrect,
  17. };
  18. // Delegate
  19. @protocol DBGuestureLockDelegate <NSObject>
  20. @required
  21. -(void)guestureLock:(DBGuestureLock *)lock didSetPassword:(NSString*)password;
  22. -(void)guestureLock:(DBGuestureLock *)lock didGetCorrectPswd:(NSString*)password;
  23. -(void)guestureLock:(DBGuestureLock *)lock didGetIncorrectPswd:(NSString*)password;
  24. @optional
  25. -(BOOL)showButtonCircleCenterPointOnState:(DBButtonState)buttonState;
  26. -(BOOL)fillButtonCircleCenterPointOnState:(DBButtonState)buttonState;
  27. -(CGFloat)widthOfButtonCircleStrokeOnState:(DBButtonState)buttonState;
  28. -(CGFloat)radiusOfButtonCircleCenterPointOnState:(DBButtonState)buttonState;
  29. -(CGFloat)lineWidthOfGuestureOnState:(DBButtonState)buttonState;
  30. -(UIColor *)colorOfButtonCircleStrokeOnState:(DBButtonState)buttonState;
  31. -(UIColor *)colorForFillingButtonCircleOnState:(DBButtonState)buttonState;
  32. -(UIColor *)colorOfButtonCircleCenterPointOnState:(DBButtonState)buttonState;
  33. -(UIColor *)lineColorOfGuestureOnState:(DBButtonState)buttonState;
  34. @end
  35. // Class
  36. @interface DBGuestureLock : UIView
  37. @property (nonatomic, readonly, assign)BOOL fillCenterPoint;
  38. @property (nonatomic, readonly, assign)BOOL showCenterPoint;
  39. @property (nonatomic, readonly, assign)CGFloat lineWidth;
  40. @property (nonatomic, readonly, assign)CGFloat circleRadius;
  41. @property (nonatomic, readonly, assign)CGFloat strokeWidth;
  42. @property (nonatomic, readonly, assign)CGFloat centerPointRadius;
  43. @property (nonatomic, readonly, strong)UIColor *lineColor;
  44. @property (nonatomic, readonly, strong)UIColor *fillColor;
  45. @property (nonatomic, readonly, strong)UIColor *strokeColor;
  46. @property (nonatomic, readonly, strong)UIColor *centerPointColor;
  47. @property (nonatomic, readonly, assign)BOOL isPasswordSetup;
  48. @property (nonatomic, copy)NSString *firstTimeSetupPassword;
  49. @property (nonatomic, assign)id<DBGuestureLockDelegate> delegate;
  50. @property (nonatomic, copy) void(^onPasswordSet)(DBGuestureLock *lock, NSString *password);
  51. @property (nonatomic, copy) void(^onGetCorrectPswd)(DBGuestureLock *lock, NSString *password);
  52. @property (nonatomic, copy) void(^onGetIncorrectPswd)(DBGuestureLock *lock, NSString *password);
  53. // Password
  54. +(BOOL)passwordSetupStatus;
  55. +(void)clearGuestureLockPassword;
  56. +(NSString *)getGuestureLockPassword;
  57. //Working with protocal
  58. +(instancetype)lockOnView:(UIView*)view delegate:(id<DBGuestureLockDelegate>)delegate;
  59. +(instancetype)lockOnView:(UIView*)view offsetFromBottom:(CGFloat)offset delegate:(id<DBGuestureLockDelegate>)delegate;
  60. //Working with block
  61. +(instancetype)lockOnView:(UIView*)view onPasswordSet:(void (^)(DBGuestureLock *lock, NSString *password))onPasswordSet onGetCorrectPswd:(void (^)(DBGuestureLock *lock, NSString *password))GetCorrectPswd onGetIncorrectPswd:(void (^)(DBGuestureLock *lock, NSString *password))GetIncorrectPswd;
  62. +(instancetype)lockOnView:(UIView*)view offsetFromBottom:(CGFloat)offset onPasswordSet:(void (^)(DBGuestureLock *lock, NSString *password))onPasswordSet onGetCorrectPswd:(void (^)(DBGuestureLock *lock, NSString *password))GetCorrectPswd onGetIncorrectPswd:(void (^)(DBGuestureLock *lock, NSString *password))GetIncorrectPswd;
  63. //Setup lock theme
  64. -(void)setupLockThemeWithLineColor:(UIColor*)lineColor lineWidth:(CGFloat)lineWidth strokeColor:(UIColor*)strokeColor strokeWidth:(CGFloat)strokeWidth circleRadius:(CGFloat)circleRadius fillColor:(UIColor*)fillColor showCenterPoint:(BOOL)showCenterPoint centerPointColor:(UIColor*)centerPointColor centerPointRadius:(CGFloat)centerPointRadius fillCenterPoint:(BOOL)fillCenterPoint onState:(DBButtonState)buttonState;
  65. @end