diff --git a/Class/DYSlideView.h b/Class/DYSlideView.h index 1e05ccd..b4da568 100644 --- a/Class/DYSlideView.h +++ b/Class/DYSlideView.h @@ -38,6 +38,7 @@ @property (strong, nonatomic) UIColor *buttonNormalColor; @property (strong, nonatomic) UIColor *buttonSelectedColor; @property (strong, nonatomic) UIFont *buttonTitleFont; +@property (strong, nonatomic) UIFont *buttonSelectedTitleFont; @property (nonatomic) BOOL scrollViewBounces; @property (nonatomic) BOOL scrollEnabled; diff --git a/Class/DYSlideView.m b/Class/DYSlideView.m index 3008abc..6162a2f 100644 --- a/Class/DYSlideView.m +++ b/Class/DYSlideView.m @@ -168,6 +168,8 @@ - (void)updateSelectedButton:(UIButton *)button{ } if (!(_selectedButton && [_slideBarButtons indexOfObject:_selectedButton] == [button tag])) { _selectedButton = button; + [_selectedButton.titleLabel setTextAlignment:NSTextAlignmentCenter]; + [_selectedButton.titleLabel setFont:_buttonSelectedTitleFont]; if (_delegate && [_delegate respondsToSelector:@selector(DY_didSelectButtonAtIndex:)]) { [self.delegate DY_didSelectButtonAtIndex:[_selectedButton tag]]; } @@ -194,7 +196,9 @@ - (void)scrollViewDidScroll:(UIScrollView *)scrollView { for (UIButton *button in _slideBarButtons) { if ([_slideBarButtons indexOfObject:button] == _currentBtnIndex) { [[_slideBarButtons objectAtIndex:_currentBtnIndex] setTitleColor:_buttonSelectedColor forState:UIControlStateNormal]; + [button.titleLabel setFont:_buttonSelectedTitleFont]; } else { + [button.titleLabel setFont:_buttonTitleFont]; [button setTitleColor:_buttonNormalColor forState:UIControlStateNormal]; } }