SHARE
TWEET

Untitled

a guest May 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //
  2. //  BadgeView.h
  3. //  BadgeView
  4. //
  5. /*Copyright (c) 2014 Brandon McQuilkin
  6.  
  7.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  8.  
  9.  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  10.  
  11.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  12.  */
  13.  
  14. #import <UIKit/UIKit.h>
  15.  
  16. typedef enum {
  17.     BadgeViewHorizontalAlignmentNone,
  18.     BadgeViewHorizontalAlignmentLeft,
  19.     BadgeViewHorizontalAlignmentCenter,
  20.     BadgeViewHorizontalAlignmentRight
  21. } BadgeViewHorizontalAlignment;
  22.  
  23. typedef enum {
  24.     BadgeViewVerticalAlignmentNone,
  25.     BadgeViewVerticalAlignmentTop,
  26.     BadgeViewVerticalAlignmentMiddle,
  27.     BadgeViewVerticalAlignmentBottom
  28. } BadgeViewVerticalAlignment;
  29.  
  30. /**A badge view similar to the standard badge for tab bar items.*/
  31. @interface BadgeView : UIView
  32.  
  33. /**@name Text*/
  34. /**The text to display in the badge.*/
  35. @property (nonatomic, retain) NSString *text;
  36. /**The color of the text.*/
  37. @property (nonatomic, retain) UIColor *textColor;
  38. /**The font of the text.*/
  39. @property (nonatomic, retain) UIFont *font;
  40. /**The distance to shift the text by when the horizontal/vertical alignment is set. This is for fine tune adjustments.*/
  41. @property (nonatomic, assign) CGSize textAlignmentShift;
  42. /**Wether or not to align the text so that it is pixel perfect. Default is YES.
  43.  @note If the text is aligned, it will be centered, and the position rounded to the nearest perfect pixel.*/
  44. @property (nonatomic, assign) BOOL pixelPerfectText;
  45.  
  46. /**@name Badge*/
  47. /**The background color of the badge.*/
  48. @property (nonatomic, retain) UIColor *badgeBackgroundColor;
  49. /**Wether or not the badge has a glossy overlay.*/
  50. @property (nonatomic, assign) BOOL showGloss;
  51. /**The corner radius of the badge.
  52.  @note This will be set automatically unless manually set.*/
  53. @property (nonatomic, assign) CGFloat cornerRadius;
  54. /**The horizontal alignment of the badge.
  55.  @note If set to none, one can set the origin.x value arbitrarily, otherwise it will be set automatically.*/
  56. @property (nonatomic, assign) BadgeViewHorizontalAlignment horizontalAlignment;
  57. /**The vertical alignment of the badge.
  58.  @note If set to none, one can set the origin.y value arbitrarily, otherwise it will be set automatically.*/
  59. @property (nonatomic, assign) BadgeViewVerticalAlignment verticalAlignment;
  60. /**The distance to shift the badge by when the horizontal/vertical alignment is set. This is for fine tune adjustments.*/
  61. @property (nonatomic, assign) CGSize alignmentShift;
  62. /**Wether or not changes in frame size are animated.*/
  63. @property (nonatomic, assign) BOOL animateChanges;
  64. /**The duration of animations.*/
  65. @property (nonatomic, assign) CGFloat animationDuration;
  66. /**The minimum width of the badge.
  67.  @note This setting only has an effect if it is larger than the height of the badge. The minimum shape will otherwise always be a circle.*/
  68. @property (nonatomic, assign) CGFloat minimumWidth;
  69. /**The maximum width of the badge.
  70.  @note This setting only has an effect if it is larger than the height of the badge. If the size of the badge exceeds this size, the text will be truncated and "..." will be tacked onto the end of the string.*/
  71. @property (nonatomic, assign) CGFloat maximumWidth;
  72. /**The badge will be hidden if the text's value is equal to 0.*/
  73. @property (nonatomic, assign) BOOL hidesWhenZero;
  74.  
  75. /**@name Border*/
  76. /**The width of the border. If set to zero, no border will be shown.*/
  77. @property (nonatomic, assign) CGFloat borderWidth;
  78. /**The color of the border if shown.*/
  79. @property (nonatomic, retain) UIColor *borderColor;
  80.  
  81. /**@name Shadow*/
  82. /**The color of the shadow.*/
  83. @property (nonatomic, retain) UIColor *shadowColor;
  84. /**The offset of the shadow.*/
  85. @property (nonatomic, assign) CGSize shadowOffset;
  86. /**The radius of the shadow.*/
  87. @property (nonatomic, assign) CGFloat shadowRadius;
  88. /**Wether or not the text has a shadow.*/
  89. @property (nonatomic, assign) BOOL shadowText;
  90. /**Wether or not the border has a shadow.*/
  91. @property (nonatomic, assign) BOOL shadowBorder;
  92. /**Wether or not the badge has a shadow.*/
  93. @property (nonatomic, assign) BOOL shadowBadge;
  94.  
  95.  
  96.  
  97.  
  98. @end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top