Skip to content

Commit

Permalink
修复 自定义 scrollIndicator 无效的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
changsanjiang committed Jul 21, 2020
1 parent 250495b commit f557f16
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion SJPageViewController.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'SJPageViewController'
s.version = '0.0.11'
s.version = '0.0.12'
s.summary = 'SJPageViewController.'

# This description is used to generate tags and improve search results.
Expand Down
10 changes: 10 additions & 0 deletions SJPageViewController/ObjC/PageMenuBar/SJPageMenuBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ - (void)setEnabledFadeOut:(BOOL)enabledFadeOut {
}
}

- (void)setScrollIndicator:(nullable UIView<SJPageMenuBarScrollIndicator> *)scrollIndicator {
if ( _scrollIndicator != scrollIndicator ) {
[_scrollIndicator removeFromSuperview];
_scrollIndicator = scrollIndicator;
[self.scrollView addSubview:self.scrollIndicator];
if ( [self _isSafeIndex:_focusedIndex] )
[self _remakeConstraintsForScrollIndicatorWithFocusedIndex:_focusedIndex];
}
}

#pragma mark -

- (UIColor *)itemTintColor {
Expand Down
9 changes: 8 additions & 1 deletion SJPageViewController/Swift/PageMenuBar/SJPageMenuBar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,14 @@ open class SJPageMenuBar: UIView {
}()

open var scrollIndicator: SJPageMenuBarScrollIndicatorProtocol {
set { _scrollIndicator = newValue }
set {
_scrollIndicator.removeFromSuperview()
_scrollIndicator = newValue
addSubview(newValue)
if ( isSafeIndex(focusedIndex) ) {
remakeConstraintsForScrollIndicator(focusedIndex)
}
}
get { return _scrollIndicator }
}

Expand Down

0 comments on commit f557f16

Please sign in to comment.