Skip to content

Instantly share code, notes, and snippets.

@jackyshan
Last active August 7, 2016 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jackyshan/856e12f1db13eaac62a2a34793220100 to your computer and use it in GitHub Desktop.
Save jackyshan/856e12f1db13eaac62a2a34793220100 to your computer and use it in GitHub Desktop.
下划线随着scrollview滑动
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
if (scrollView.tag == 318) {
self.currentPage = (NSInteger)((scrollView.contentOffset.x + FUll_VIEW_WIDTH / 2) / FUll_VIEW_WIDTH);
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if (scrollView.tag == 318) {
NSInteger yourPage = (NSInteger)((scrollView.contentOffset.x + FUll_VIEW_WIDTH / 2) / FUll_VIEW_WIDTH);
CGFloat additionCount = 0;
CGFloat yourCount = 1.0 / arrayCount;
if (arrayCount > 5) {
additionCount = (arrayCount - 5.0) / 5.0;
yourCount = 1.0 / 5.0;
__lineBottom.frame = CGRectMake(scrollView.contentOffset.x / 5, PageBtn - 2, yourCount * FUll_VIEW_WIDTH, 1);__
}else {
lineBottom.frame = CGRectMake(scrollView.contentOffset.x / arrayCount, PageBtn - 2, yourCount * FUll_VIEW_WIDTH, 1);
}
for (NSInteger i = 0; i < btnArray.count; i++) {
if (unselectBtn) {
[btnArray[i] setTitleColor:unselectBtn forState:UIControlStateNormal];
}else {
[btnArray[i] setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
}
UIButton *changeButton = btnArray[i];
[UIView animateWithDuration:0.3 animations:^{
changeButton.transform = CGAffineTransformMakeScale(1, 1);
}];
}
if (selectBtn) {
[btnArray[yourPage] setTitleColor:selectBtn forState:UIControlStateNormal];
}else {
[btnArray[yourPage] setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
}
UIButton *changeButton = btnArray[yourPage];
[UIView animateWithDuration:0.3 animations:^{
changeButton.transform = CGAffineTransformMakeScale(1.15, 1.15);
}];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment