A way to quickly add a notification icon to a UIButton
###DEMO
Take any button
Code:
RKNotificationHub* hub = [[RKNotificationHub alloc]init];
[hub setButton:button andCount:1]; //%%% the initial count
[hub increment];
Other Options
-(void)increment;
-(void)incrementBy:(int)amount;
-(void)decrement;
-(void)decrementBy:(int)amount;
-(void)setCount:(int)currentCount; //%%% set to a certain number
//%%% using a set (see below)
@property (nonatomic)NSMutableSet* objectsSet;
-(void)updateWithSetCount;
//%%% using an array
@property (nonatomic)NSMutableArray* objectArray;
-(void)updateWithArrayCount;
[hub pop];
[hub bump];
[hub blink];
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)];
###USING SETS OR ARRAYS If you have your own array (say an array of notifications or an array of messages), you can use this section so that you don't have to manually change the count
//%%% using a set
@property (nonatomic)NSMutableSet* objectSet;
-(void)updateWithSetCount;
//%%% using an array
@property (nonatomic)NSMutableArray* objectArray;
-(void)updateWithArrayCount;
Using a set
hub.objectSet = yourSet;
[hub updateWithSetCount];
//%%% or
[hub.objectSet addObject:@"a unique id of a message"];
[hub updateWithSetCount];
//%%% this will increment the count by one if that id doesn't already exist in the set
Using an array
hub.objectArray = yourArray;
[hub updateWithArrayCount];
//%%% or
[hub.objectArray addObject:@"a unique id of a message"];
[hub updateWithArrayCount];
//%%% this will increment the count by one regardless of whether that id exists already
Of course you can do the other standard set / array operations (removing objects, printing them, looping through them, etc)