TOPasscodeKeypadView.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //
  2. // TOPasscodeKeypadView.h
  3. //
  4. // Copyright 2017 Timothy Oliver. All rights reserved.
  5. //
  6. // Permission is hereby granted, free of charge, to any person obtaining a copy
  7. // of this software and associated documentation files (the "Software"), to
  8. // deal in the Software without restriction, including without limitation the
  9. // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  10. // sell copies of the Software, and to permit persons to whom the Software is
  11. // furnished to do so, subject to the following conditions:
  12. //
  13. // The above copyright notice and this permission notice shall be included in
  14. // all copies or substantial portions of the Software.
  15. //
  16. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  17. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  20. // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
  21. // IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. #import <UIKit/UIKit.h>
  23. NS_ASSUME_NONNULL_BEGIN
  24. @class TOPasscodeCircleButton;
  25. /**
  26. A view encompassing 9 circle buttons, making up a keypad view for entering PIN numbers.
  27. Can be laid out vertically or horizontally.
  28. */
  29. @interface TOPasscodeKeypadView : UIView <UIInputViewAudioFeedback>
  30. /** The type of layout for the buttons (Default is vertical) */
  31. @property (nonatomic, assign) BOOL horizontalLayout;
  32. /** The vibrancy effect to be applied to each button background */
  33. @property (nonatomic, strong, nullable) UIVibrancyEffect *vibrancyEffect;
  34. /** The size of each input button */
  35. @property (nonatomic, assign) CGFloat buttonDiameter;
  36. /** The stroke width of the buttons */
  37. @property (nonatomic, assign) CGFloat buttonStrokeWidth;
  38. /** The spacing between the buttons. Default is (CGSize){25,15} */
  39. @property (nonatomic, assign) CGSize buttonSpacing;
  40. /** The font of the number in each button */
  41. @property (nonatomic, strong) UIFont *buttonNumberFont;
  42. /** The font of the lettering label */
  43. @property (nonatomic, strong) UIFont *buttonLetteringFont;
  44. /** The spacing between the lettering and the number label */
  45. @property (nonatomic, assign) CGFloat buttonLabelSpacing;
  46. /** The spacing between the letters in the lettering label */
  47. @property (nonatomic, assign) CGFloat buttonLetteringSpacing;
  48. /** Show the 'ABC' lettering under the numbers */
  49. @property (nonatomic, assign) BOOL showLettering;
  50. /** The spacing in points between the letters */
  51. @property (nonatomic, assign) CGFloat letteringSpacing;
  52. /** The tint color of the button backgrounds */
  53. @property (nonatomic, strong) UIColor *buttonBackgroundColor;
  54. /** The color of the text elements in each button */
  55. @property (nonatomic, strong) UIColor *buttonTextColor;
  56. /** Optionally the color of text when it's tapped. */
  57. @property (nonatomic, strong, nullable) UIColor *buttonHighlightedTextColor;
  58. /** The alpha value of all non-translucent views */
  59. @property (nonatomic, assign) CGFloat contentAlpha;
  60. /** Accessory views placed on either side of the '0' button */
  61. @property (nonatomic, strong, nullable) UIView *leftAccessoryView;
  62. @property (nonatomic, strong, nullable) UIView *rightAccessoryView;
  63. /** The controls making up each of the button views */
  64. @property (nonatomic, readonly) NSArray<TOPasscodeCircleButton *> *keypadButtons;
  65. /** The block that is triggered whenever a user taps one of the buttons */
  66. @property (nonatomic, copy) void (^buttonTappedHandler)(NSInteger buttonNumber);
  67. /*
  68. Perform an animation to transition to a new layout.
  69. @param horizontalLayout The content is laid out horizontally.
  70. @param animated Whether the transition is animated
  71. @param duration The animation length of the transition.
  72. */
  73. - (void)setHorizontalLayout:(BOOL)horizontalLayout animated:(BOOL)animated duration:(CGFloat)duration;
  74. @end
  75. NS_ASSUME_NONNULL_END