Skip to content

Instantly share code, notes, and snippets.

@jverkoey
Created June 23, 2012 07:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jverkoey/2977465 to your computer and use it in GitHub Desktop.
Save jverkoey/2977465 to your computer and use it in GitHub Desktop.
NIBadgeView Example 1
// We don't know what the initial frame will be, so pass the empty rect.
NIBadgeView* badgeView = [[NIBadgeView alloc] initWithFrame:CGRectZero];
// The badgeView backgroundColor is black by default.
badgeView.backgroundColor = self.view.backgroundColor;
// We can set any arbitrary text to the badge view.
badgeView.text = @"7";
// Once we've set the text we allow the badge view to size itself to fit the contents of the
// text. If we wanted to we could explicitly set the frame of the badge view to something larger,
// but in nearly all cases the sizeToFit rect will be the one you want to use.
[badgeView sizeToFit];
[self.view addSubview:badgeView];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment