The iOS framework that grows only as fast as its documentation
NIBadgeView Class Reference

Overview

A view that mimics the iOS notification badge style.

Any NSString can be displayed in this view, though in practice you should only show numbers ranging from 1...99 or the string "99+". Apple is quite consistent about using the red badge views to represent notification badges, so you should do your best not to attach additional meaning to the red badge.

On devices running operating systems that support the tintColor property on UIViews, these badges will use the tintColor by default. This behavior may be overwritten by assigning a tint color explicitly.

badge.png
A default NIBadgeView
badgetinted.png
A NIBadgeView on tintColor-supporting devices

Tasks

Accessing the Text Attributes
NSString * text property
 
UIFont * font property
 
UIColor * textColor property
 
Accessing the Badge Attributes
UIColor * tintColor property
 
UIColor * shadowColor property
 
CGSize shadowOffset property
 
CGFloat shadowBlur property
 

Method Documentation

text

The text displayed within the badge.

@property (nonatomic, copy) NSString* text;
Discussion

As with a UILabel you should call sizeToFit after setting the badgeView properties so that it will update its frame to fit the contents.

font

The font of the text within the badge.

@property (nonatomic, strong) UIFont* font;
Discussion

The default font is:

iOS 6: [UIFont boldSystemFontOfSize:17] iOS 7: [UIFont systemFontOfSize:16]

See Also
text

textColor

The color of the text in the badge.

@property (nonatomic, strong) UIColor* textColor;
Discussion

The default color is [UIColor whiteColor].

tintColor

The tint color of the badge.

@property (nonatomic, strong) UIColor* tintColor;
Discussion

This is the color drawn within the badge's borders.

The default color is

iOS 6: [UIColor redColor]. iOS 7: self.tintColor

On devices that support global tintColor (iOS 7) the global tint color is used unless a tint color has been explicitly assigned to this badge view, in which case the assigned tint color will be used.

shadowColor

The shadow color of the badge.

@property (nonatomic, strong) UIColor* shadowColor;
Discussion

This is the shadow drawn beneath the badge's outline.

The default color is

iOS 6: [UIColor colorWithWhite:0 alpha:0.5]. iOS 7: nil

On devices that support global tintColor (iOS 7) it is possible, though not encouraged, to use a shadow on badges.

See Also
shadowOffset
shadowBlur

shadowOffset

The shadow offset (measured in points) for the badge.

@property (nonatomic) CGSize shadowOffset;
Discussion

This is the offset of the shadow drawn beneath the badge's outline.

The default value is CGSizeMake(0, 3.f).

See Also
shadowColor
shadowBlur

shadowBlur

The shadow blur (measured in points) for the badge.

@property (nonatomic) CGFloat shadowBlur;
Discussion

This is the blur of the shadow drawn beneath the badge's outline.

The default value is 3.

See Also
shadowOffset
shadowColor