自定义滚动条
作者:
iOSCoder | 来源:发表于
2018-05-17 19:23 被阅读8次
计算其滑动距离
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if ([self.collectionView isEqual:scrollView]) {
//计算偏移量
CGFloat offsetX = self.collectionView.contentOffset.x;
//150----滚动条的总长度
CGFloat X = offsetX*(150-self.line.frame.size.width)/(self.collectionView.contentSize.width-self.collectionView.frame.size.width);
[self.line mas_updateConstraints:^(MASConstraintMaker *make) {
make.left.mas_equalTo(X);
}];
[self.line.superview layoutIfNeeded];
}
}
本文标题:自定义滚动条
本文链接:https://www.haomeiwen.com/subject/jmsidftx.html
网友评论