From 2a1b2c81f9dba891cca6266af533f56cd2b204a8 Mon Sep 17 00:00:00 2001 From: Ricardo Santos Date: Fri, 15 Dec 2017 17:12:34 +1030 Subject: [PATCH] Update the badge position more frequently --- UIView+MGBadgeView.m | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/UIView+MGBadgeView.m b/UIView+MGBadgeView.m index 2bd6e66..09826e5 100644 --- a/UIView+MGBadgeView.m +++ b/UIView+MGBadgeView.m @@ -42,6 +42,8 @@ - (instancetype)initWithFrame:(CGRect)frame { } - (void)drawRect:(CGRect)rect { + [self mg_updateBadgeViewSize]; + [self mg_updateBadgeViewPosition]; if(_badgeValue != 0 || _displayIfZero) { @@ -83,9 +85,7 @@ - (void)setBadgeValue:(NSInteger)badgeValue { if(badgeValue != 0 || _displayIfZero) { [self mg_updateBadgeViewSize]; - - if(_position == MGBadgePositionBest) - [self mg_updateBadgeViewPosition]; + [self mg_updateBadgeViewPosition]; } else { self.frame = CGRectZero; @@ -107,9 +107,7 @@ - (void)setMinDiameter:(float)minDiameter { if (_minDiameter != minDiameter) { _minDiameter = minDiameter; - if(_position == MGBadgePositionBest) - [self mg_updateBadgeViewPosition]; - + [self mg_updateBadgeViewPosition]; [self setNeedsDisplay]; } } @@ -139,9 +137,7 @@ - (void)setOutlineWidth:(float)outlineWidth { if(_outlineWidth != outlineWidth) { _outlineWidth = outlineWidth; - if(_position == MGBadgePositionBest) - [self mg_updateBadgeViewPosition]; - + [self mg_updateBadgeViewPosition]; [self setNeedsDisplay]; } } @@ -151,11 +147,7 @@ - (void)setFont:(UIFont *)font { _font = font; [self mg_updateBadgeViewSize]; - - if(_position == MGBadgePositionBest) - [self mg_updateBadgeViewPosition]; - - + [self mg_updateBadgeViewPosition]; [self setNeedsDisplay]; } } @@ -167,9 +159,7 @@ - (void)setDisplayIfZero:(BOOL)displayIfZero { if(_badgeValue == 0) { if(_displayIfZero) { [self mg_updateBadgeViewSize]; - - if(_position == MGBadgePositionBest) - [self mg_updateBadgeViewPosition]; + [self mg_updateBadgeViewPosition]; } else { self.frame = CGRectZero; }