Created
June 23, 2012 07:54
-
-
Save jverkoey/2977465 to your computer and use it in GitHub Desktop.
NIBadgeView Example 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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