UIView+WZLBadge.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. //
  2. // UIView+WZLBadge.h
  3. // WZLBadgeDemo
  4. //
  5. // Created by zilin_weng on 15/6/24.
  6. // Copyright (c) 2015年 Weng-Zilin. All rights reserved.
  7. // Project description: this is a solution to enable any UIView to display badge
  8. #import <UIKit/UIKit.h>
  9. #import "WZLBadgeProtocol.h"
  10. #pragma mark -- badge apis
  11. @interface UIView (WZLBadge)<WZLBadgeProtocol>
  12. @property (nonatomic, strong) UILabel *badge; /* badge entity, which is adviced not to set manually */
  13. @property (nonatomic, strong) UIFont *badgeFont; /* [UIFont boldSystemFontOfSize:9] by default if not set */
  14. @property (nonatomic, strong) UIColor *badgeBgColor; /* red color by default if not set */
  15. @property (nonatomic, strong) UIColor *badgeTextColor; /* white color by default if not set */
  16. @property (nonatomic, assign) CGRect badgeFrame; /* we have optimized the badge frame and center.
  17. This property is adviced not to set manually */
  18. @property (nonatomic, assign) CGPoint badgeCenterOffset;/* offset from right-top corner. {0,0} by default */
  19. /* For x, negative number means left offset
  20. For y, negative number means bottom offset*/
  21. @property (nonatomic, assign) WBadgeAnimType aniType; /* NOTE that this is not animation type of badge's
  22. appearing, nor hidding*/
  23. @property (nonatomic, assign) NSInteger badgeMaximumBadgeNumber; /*for WBadgeStyleNumber style badge,
  24. if badge value is above badgeMaximumBadgeNumber,
  25. "badgeMaximumBadgeNumber+" will be printed. */
  26. /**
  27. * show badge with red dot style and WBadgeAnimTypeNone by default.
  28. */
  29. - (void)showBadge;
  30. /**
  31. * showBadge
  32. *
  33. * @param style WBadgeStyle type
  34. * @param value (if 'style' is WBadgeStyleRedDot or WBadgeStyleNew,
  35. this value will be ignored. In this case, any value will be ok.)
  36. * @param aniType
  37. */
  38. - (void)showBadgeWithStyle:(WBadgeStyle)style
  39. value:(NSInteger)value
  40. animationType:(WBadgeAnimType)aniType;
  41. /**
  42. * clear badge(hide badge)
  43. */
  44. - (void)clearBadge;
  45. /**
  46. * make bage(if existing) not hiden
  47. */
  48. - (void)resumeBadge;
  49. @end