BKPasscodeField.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // BKPasscodeField.h
  3. // BKPasscodeViewDemo
  4. //
  5. // Created by Byungkook Jang on 2014. 4. 20..
  6. // Copyright (c) 2014년 Byungkook Jang. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. @protocol BKPasscodeFieldDelegate;
  10. @protocol BKPasscodeFieldImageSource;
  11. @interface BKPasscodeField : UIControl <UIKeyInput>
  12. // delegate
  13. @property (nonatomic, weak) id<BKPasscodeFieldDelegate> delegate;
  14. @property (nonatomic, weak) id<BKPasscodeFieldImageSource> imageSource;
  15. // passcode
  16. @property (nonatomic, strong) NSString *passcode;
  17. // configurations
  18. @property (nonatomic) NSUInteger maximumLength;
  19. @property (nonatomic) CGSize dotSize;
  20. @property (nonatomic) CGFloat lineHeight;
  21. @property (nonatomic) CGFloat dotSpacing;
  22. @property (nonatomic, strong) UIColor *dotColor;
  23. @property (nonatomic) UIKeyboardType keyboardType;
  24. @end
  25. @protocol BKPasscodeFieldDelegate <NSObject>
  26. @optional
  27. /**
  28. * Ask the delegate that whether passcode field accepts text.
  29. * If you want to accept entering text, return YES.
  30. */
  31. - (BOOL)passcodeField:(BKPasscodeField *)aPasscodeField shouldInsertText:(NSString *)aText;
  32. /**
  33. * Ask the delegate that whether passcode can be deleted.
  34. * If you want to accept deleting passcode, return YES.
  35. */
  36. - (BOOL)passcodeFieldShouldDeleteBackward:(BKPasscodeField *)aPasscodeField;
  37. @end
  38. @protocol BKPasscodeFieldImageSource <NSObject>
  39. @optional
  40. /**
  41. * Ask the image source for a image to display passcode digit at index.
  42. * If you don't implement this, default shape (line for blank digit and circule for filled digit) will be displayed.
  43. */
  44. - (UIImage *)passcodeField:(BKPasscodeField *)aPasscodeField dotImageAtIndex:(NSInteger)aIndex filled:(BOOL)aFilled;
  45. @end