TOPasscodeCircleButton.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // TOPasscodeCircleButton.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. @class TOPasscodeCircleView;
  24. @class TOPasscodeButtonLabel;
  25. NS_ASSUME_NONNULL_BEGIN
  26. /**
  27. A UI control representing a single PIN code button for the keypad,
  28. including the number, lettering (eg 'ABC'), and circle border.
  29. */
  30. @interface TOPasscodeCircleButton : UIControl
  31. // Alpha value that properly controls the necessary subviews
  32. @property (nonatomic, assign) CGFloat contentAlpha;
  33. // Required to be set before this view can be properly rendered
  34. @property (nonatomic, strong) UIImage *backgroundImage;
  35. @property (nonatomic, strong) UIImage *hightlightedBackgroundImage;
  36. @property (nonatomic, strong) UIVibrancyEffect *vibrancyEffect;
  37. // Properties with default values
  38. @property (nonatomic, strong) UIColor *textColor;
  39. @property (nonatomic, strong, nullable) UIColor *highlightedTextColor;
  40. @property (nonatomic, strong) UIFont *numberFont;
  41. @property (nonatomic, strong) UIFont *letteringFont;
  42. @property (nonatomic, assign) CGFloat letteringCharacterSpacing;
  43. @property (nonatomic, assign) CGFloat letteringVerticalSpacing;
  44. @property (nonatomic, readonly) NSString *numberString;
  45. @property (nonatomic, readonly) NSString *letteringString;
  46. // The internal views
  47. @property (nonatomic, readonly) TOPasscodeButtonLabel *buttonLabel;
  48. @property (nonatomic, readonly) TOPasscodeCircleView *circleView;
  49. @property (nonatomic, readonly) UIVisualEffectView *vibrancyView;
  50. // Callback handler
  51. @property (nonatomic, copy) void (^buttonTappedHandler)(void);
  52. /**
  53. Create a new instance of the class with the supplied number and lettering string
  54. @param numberString The string of the number to display in this button (eg '1').
  55. @param letteringString The string of the lettering to display underneath.
  56. */
  57. - (instancetype)initWithNumberString:(NSString *)numberString letteringString:(NSString *)letteringString;
  58. /**
  59. Set the background of the button to be the filled circle instead of hollow.
  60. @param highlighted When YES, the circle is full, when NO, it is hollow.
  61. @param animated When animated, the transition is a crossfade.
  62. */
  63. - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;
  64. @end
  65. NS_ASSUME_NONNULL_END