diff --git a/TAPageControl/TAPageControl.h b/TAPageControl/TAPageControl.h index 2fa5c83..4256888 100644 --- a/TAPageControl/TAPageControl.h +++ b/TAPageControl/TAPageControl.h @@ -10,7 +10,6 @@ @protocol TAPageControlDelegate; - @interface TAPageControl : UIControl @@ -39,13 +38,15 @@ /** * Dot size for dot views. Default is 8 by 8. */ -@property (nonatomic) CGSize dotSize; + +@property (nonatomic) IBInspectable CGSize dotSize; /** * Spacing between two dot views. Default is 8. */ -@property (nonatomic) NSInteger spacingBetweenDots; + +@property (nonatomic) IBInspectable NSInteger spacingBetweenDots; /** @@ -62,25 +63,25 @@ /** * Number of pages for control. Default is 0. */ -@property (nonatomic) NSInteger numberOfPages; +@property (nonatomic) IBInspectable NSInteger numberOfPages; /** * Current page on which control is active. Default is 0. */ -@property (nonatomic) NSInteger currentPage; +@property (nonatomic) IBInspectable NSInteger currentPage; /** * Hide the control if there is only one page. Default is NO. */ -@property (nonatomic) BOOL hidesForSinglePage; +@property (nonatomic) IBInspectable BOOL hidesForSinglePage; /** * Let the control know if should grow bigger by keeping center, or just get longer (right side expanding). By default YES. */ -@property (nonatomic) BOOL shouldResizeFromCenter; +@property (nonatomic) IBInspectable BOOL shouldResizeFromCenter; /** diff --git a/TAPageControl/TAPageControl.m b/TAPageControl/TAPageControl.m index 10a4432..b8f6fb2 100644 --- a/TAPageControl/TAPageControl.m +++ b/TAPageControl/TAPageControl.m @@ -102,6 +102,7 @@ - (void)initialization self.currentPage = kDefaultCurrentPage; self.hidesForSinglePage = kDefaultHideForSinglePage; self.shouldResizeFromCenter = kDefaultShouldResizeFromCenter; + _dotSize = kDefaultDotSize; } @@ -311,27 +312,44 @@ - (void)setCurrentPage:(NSInteger)currentPage - (void)setDotImage:(UIImage *)dotImage { - _dotImage = dotImage; - [self resetDotViews]; - self.dotViewClass = nil; + if (_dotImage != dotImage) + { + _dotImage = dotImage; + self.dotSize = _dotImage.size; + [self resetDotViews]; + self.dotViewClass = nil; + } } - (void)setCurrentDotImage:(UIImage *)currentDotimage { - _currentDotImage = currentDotimage; - [self resetDotViews]; - self.dotViewClass = nil; + if (_currentDotImage != currentDotimage) + { + _currentDotImage = currentDotimage; + [self resetDotViews]; + self.dotViewClass = nil; + } } - (void)setDotViewClass:(Class)dotViewClass { - _dotViewClass = dotViewClass; - self.dotSize = CGSizeZero; - [self resetDotViews]; + if (_dotViewClass != dotViewClass) + { + _dotViewClass = dotViewClass; + [self resetDotViews]; + } } +- (void)setDotSize:(CGSize)dotSize +{ + if (_dotSize.height != dotSize.height || _dotSize.width != dotSize.width) + { + _dotSize = dotSize; + [self resetDotViews]; + } +} #pragma mark - Getters @@ -345,18 +363,4 @@ - (NSMutableArray *)dots return _dots; } - -- (CGSize)dotSize -{ - // Dot size logic depending on the source of the dot view - if (self.dotImage && CGSizeEqualToSize(_dotSize, CGSizeZero)) { - _dotSize = self.dotImage.size; - } else if (self.dotViewClass && CGSizeEqualToSize(_dotSize, CGSizeZero)) { - _dotSize = kDefaultDotSize; - return _dotSize; - } - - return _dotSize; -} - @end