Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 51 lines (34 sloc) 1.723 kb
4417782 Initial checkin
Robert Rasmussen authored
1 UIView+Badge
2 ==============
3
4 A simple addition to UIView that allows any view to display a badge, similar to the
5 badge Apple provides for UITabBarItem.
6
7 Usage
8 =====
9 The Xcode project includes an example view controller. To use in your own project:
10
11 1. Drag UIView+Badge.h and UIView+Badge.m into your project.
12
13 2. Import the header file, and set the badge value via the <code>badge</code> accessor
14 on UIView.
15
16
17 #import <UIKit/UIKit.h>
18 #import "UIView+Badge.h"
19
20 @implementation MyController
21 -(void)viewDidLoad {
22 self.button.badge.badgeColor = [UIColor orangeColor];
23 self.button.badge.badgeValue = 13;
24 }
25 @end
26
27
28 Note: Setting the badgeValue on a UIView's badge will cause it to be laid out. It's best
29 to set all other display-related options that effect the display area (e.g. font) before
30 setting the badgeValue.
31
32 Display Options
33 ===============
34
35 The badge view has several properties that affect how it looks:
36
37 1. <code>placement</code>: By default, the badge will be placed on the right side of the view,
38 assuming there's room. Setting the placement to kBadgePlacementLeft or kBadgePlacementRight
39 allows you to be explicit about where the badge renders.
40
41 2. <code>font</code>: The font the number inside the badge will use. The size of the badge
42 is adjusted for this.
43
44 3. <code>badgeColor</code>: The background color inside the badge.
45
46 4. <code>outlineColor</code>: The color of the outline around the badge.
47
48 5. <code>outlineWidth</code>: The width of the outline around the badge.
49
50 6. <code>displayWhenZero</code>: The badge normally doesn't render if the badgeValue is zero.
51 This setting allows you to override that.
Something went wrong with that request. Please try again.