Merge pull request #1 from iznv/remove_text_from_dot

Remove text from dot
This commit is contained in:
Ivan Zinovyev 2018-11-27 12:28:57 +03:00 committed by GitHub
commit 15bcbce38b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 42 additions and 91 deletions

View File

@ -57,7 +57,6 @@
@property (nonatomic) NSInteger currentDisplayedPage;
@property (nonatomic) NSInteger previousDisplayPage;
@property (nonatomic) UILabel *indicatorIndexLabel;
@end
@ -119,38 +118,9 @@
_currentPageIndexTextFont = [UIFont systemFontOfSize:0];
[self loadIndicatorIndexLabel];
[self setBackgroundColor:[UIColor clearColor]];
}
- (void)loadIndicatorIndexLabel {
CGFloat width = MAX(RCDefaultIndicatorDotIndexDisplayMinWidth, [self _scaledDotMaxWidth]);
if (_indicatorIndexLabel) {
[_indicatorIndexLabel setFrame:CGRectMake(0, 0, width, width)];
} else {
_indicatorIndexLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, width, width)];
[_indicatorIndexLabel setTextAlignment:NSTextAlignmentCenter];
[_indicatorIndexLabel setBackgroundColor:[UIColor clearColor]];
}
[_indicatorIndexLabel setTextColor:_currentPageIndexTextTintColor];
[_indicatorIndexLabel setFont:[_currentPageIndexTextFont fontWithSize:[self _scaledDotMaxWidth] * 2 / 3]];
[_indicatorIndexLabel setHidden:_hideCurrentPageIndex];
UIView *dot = [self _currentDisplayedDot];
if (dot) {
[_indicatorIndexLabel setCenter:dot.center];
} else {
[_indicatorIndexLabel setHidden:YES];
}
}
#pragma mark - Properties
- (void)setNumberOfPages:(NSInteger)numberOfPages {
@ -192,7 +162,6 @@
if ( !IsFloatEqualToFloat(_indicatorDotWidth, width)) {
_indicatorDotWidth = width;
[self loadIndicatorIndexLabel];
[self _refreshIndicator:YES];
}
}
@ -201,7 +170,6 @@
if ( _animationScaleFactor != animationScaleFactor) {
_animationScaleFactor = MAX(RCDefaultIndicatorDotScaleFactorMinValue, animationScaleFactor);
[self loadIndicatorIndexLabel];
[self _dotScaleAnimationAtIndex:_currentDisplayedPage withProgress:RCDefaultIndicatorDotChangeProgressMaxValue];
}
}
@ -223,7 +191,6 @@
- (void)setHideCurrentPageIndex:(BOOL)hideCurrentPageIndex {
if (_hideCurrentPageIndex != hideCurrentPageIndex) {
_hideCurrentPageIndex = hideCurrentPageIndex;
[self loadIndicatorIndexLabel];
}
}
@ -244,14 +211,12 @@
- (void)setCurrentPageIndexTintColor:(UIColor *)currentPageIndexTintColor {
if ( ![_currentPageIndexTextTintColor isEqual:currentPageIndexTintColor]) {
_currentPageIndexTextTintColor = currentPageIndexTintColor;
[self loadIndicatorIndexLabel];
}
}
- (void)setCurrentPageIndexTextFont:(UIFont *)currentPageIndexTextFont {
if ( ![_currentPageIndexTextFont isEqual:currentPageIndexTextFont]) {
_currentPageIndexTextFont = currentPageIndexTextFont;
[self loadIndicatorIndexLabel];
}
}
@ -372,19 +337,11 @@
BOOL hidden = ![self _dotAtIndex:toPage] || ([self _scaledDotMaxWidth] < RCDefaultIndicatorDotIndexDisplayMinWidth) || (progress < 1 - RCDefaultIndicatorDotChangeProgressMinValue) || _hideCurrentPageIndex;
[_indicatorIndexLabel setHidden:hidden];
if ( !hidden) {
[self bringSubviewToFront:_indicatorIndexLabel];
[_indicatorIndexLabel setCenter:[self _dotAtIndex:toPage].center];
[_indicatorIndexLabel setText:[NSString stringWithFormat:@"%@", @(toPage + 1)]];
POPBasicAnimation *alphaAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewAlpha];
alphaAnimation.fromValue = @(0.f);
alphaAnimation.toValue = @(1.f);
alphaAnimation.duration = _disableAnimation ? 0 : _animationDuration;
[_indicatorIndexLabel pop_addAnimation:alphaAnimation forKey:RCDefaultIndicatorIndexLabelAlphaAnimationKey];
}
}
}
@ -440,12 +397,6 @@
[self _animateIndicator:forceRefresh];
}
if ( !_indicatorIndexLabel.superview) {
[self addSubview:_indicatorIndexLabel];
}
[self bringSubviewToFront:_indicatorIndexLabel];
} else {
[self setHidden:YES];
}