为 UIView(iOS6及以上版本)快速添加一个通知图标的方法。支持更多帮助
代码
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
组合动作!
[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 */
通知没有显示出来!
[increment]
[self.view addSubview: yourView]
?)[hideCount]
。请使用 [showCount]
进行补偿增加/减少不当!
圆形位置不正常
[scaleCircleSizeBy:]
。0.5 将获得一半大小,2 将获得双倍大小[moveCircleByX: Y:]
。这将根据给定的像素数移动圆形[setCircleAtFrame:]
并提供您自己的 CGRect其他事情不正常
NSUInteger
(删除了对负数的支持),将局部常量定义为 static const