A way to quickly add a notification icon to a UIView (iOS6 and up). Support
Code:
RKNotificationHub* hub = [[RKNotificationHub alloc]initWithView:yourView]; // sets the count to 0
[hub increment]; // increments the count to 1, making the notification visible
pod 'RKNotificationHub'
[hub increment];
-(void)increment;
-(void)incrementBy:(int)amount;
-(void)decrement;
-(void)decrementBy:(int)amount;
@property (nonatomic, assign) int count; //%%% set to a certain number
Combine Actions!
[hub increment];
[hub pop];
//%%% COLOR
[hub setCircleColor:[UIColor colorWithRed:0.98 green:0.66 blue:0.2 alpha:1]
labelColor:[UIColor whiteColor]];
//%%% CIRCLE FRAME
[hub setCircleAtFrame:CGRectMake(-10, -10, 30, 30)]; //frame relative to the view you set it to
//%%% MOVE FRAME
[hub moveCircleByX:-5 Y:5]; // moves the circle 5 pixels left and down from its current position
//%%% CIRCLE SIZE
[hub scaleCircleSizeBy:2]; // doubles the size of the circle, keeps the same center
//%%% BLANK BADGE
[hub hideCount];
/* shoutout to imkevinxu for this suggestion */
Notification isn't showing up!
[increment]
[self.view addSubview: yourView]
?)[hideCount]
anywhere. Call [showCount]
to counter thisIt isn't incrementing / decrementing properly!
The circle is in a weird place
[scaleCircleSizeBy:]
. 0.5 will give you half the size, 2 will give you double[moveCircleByX: Y:]
. This shifts the circle by the number of pixels given[setCircleAtFrame:]
and give it your own CGRectSomething else isn't working properly
NSUInteger
(removed support for negative counts), made local constants static const