Skip to content

Commit

Permalink
【对标题文字默认、选中状态下颜色记录的优化处理】
Browse files Browse the repository at this point in the history
  • Loading branch information
kingsic committed Aug 29, 2018
1 parent 385ae1b commit 32840e5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
22 changes: 11 additions & 11 deletions SGPagingView/SGPageTitle/SGPageTitleView.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ - (void)setupSubviews {
// 2、添加标题按钮
[self setupTitleButtons];
// 3、添加底部分割线
if (self.configure.showBottomSeparator == YES) {
if (self.configure.showBottomSeparator) {
[self addSubview:self.bottomSeparator];
}
// 4、添加指示器
if (self.configure.showIndicator == YES) {
if (self.configure.showIndicator) {
[self.scrollView insertSubview:self.indicatorView atIndex:0];
}
}
Expand Down Expand Up @@ -246,12 +246,9 @@ - (void)setupTitleButtons {
[btn addTarget:self action:@selector(P_btn_action:) forControlEvents:(UIControlEventTouchUpInside)];
[self.btnMArr addObject:btn];
[self.scrollView addSubview:btn];

[self setupStartColor:self.configure.titleColor];
[self setupEndColor:self.configure.titleSelectedColor];


// 2、添加按钮之间的分割线
if (self.configure.showVerticalSeparator == YES) {
if (self.configure.showVerticalSeparator) {
UIView *VSeparator = [[UIView alloc] init];
if (index != 0) {
CGFloat VSeparatorX = btnW * index - 0.5;
Expand Down Expand Up @@ -294,11 +291,8 @@ - (void)setupTitleButtons {
[self.btnMArr addObject:btn];
[self.scrollView addSubview:btn];

[self setupStartColor:self.configure.titleColor];
[self setupEndColor:self.configure.titleSelectedColor];

// 2、添加按钮之间的分割线
if (self.configure.showVerticalSeparator == YES) {
if (self.configure.showVerticalSeparator) {
UIView *VSeparator = [[UIView alloc] init];
if (index < titleCount - 1) {
CGFloat VSeparatorX = btnX - 0.5;
Expand All @@ -311,6 +305,12 @@ - (void)setupTitleButtons {
CGFloat scrollViewWidth = CGRectGetMaxX(self.scrollView.subviews.lastObject.frame);
self.scrollView.contentSize = CGSizeMake(scrollViewWidth, SGPageTitleViewHeight);
}

// 标题文字渐变效果下对标题文字默认、选中状态下颜色的记录
if (self.configure.titleGradientEffect) {
[self setupStartColor:self.configure.titleColor];
[self setupEndColor:self.configure.titleSelectedColor];
}
}

#pragma mark - - - 标题按钮的点击事件
Expand Down
1 change: 1 addition & 0 deletions SGPagingViewExample/MainVC/DefaultScrollVC.m
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ - (void)setupPageView {
NSArray *titleArr = @[@"精选", @"电影", @"电视剧", @"综艺", @"NBA", @"娱乐", @"动漫", @"演唱会", @"VIP会员"];
SGPageTitleViewConfigure *configure = [SGPageTitleViewConfigure pageTitleViewConfigure];
configure.indicatorAdditionalWidth = 10; // 说明:指示器额外增加的宽度,不设置,指示器宽度为标题文字宽度;若设置无限大,则指示器宽度为按钮宽度
configure.titleGradientEffect = YES;

/// pageTitleView
self.pageTitleView = [SGPageTitleView pageTitleViewWithFrame:CGRectMake(0, pageTitleViewY, self.view.frame.size.width, 44) delegate:self titleNames:titleArr configure:configure];
Expand Down

0 comments on commit 32840e5

Please sign in to comment.