Cod*_*ker 3 objective-c uiscrollview ios
我无法找到任何适合这种粘性问题的地方.我的问题是当用户开始滚动时我需要更改alpha值.滚动alpha值的开始应该是1,然后在滚动的中间值alpha值应为0.5,at结束它必须是0.这是我需要做的.我用谷歌搜索找不到.帮帮我
els*_*ooo 23
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
/* This is the offset at the bottom of the scroll view. */
CGFloat totalScroll = scrollView.contentSize.height - scrollView.bounds.size.height;
/* This is the current offset. */
CGFloat offset = - scrollView.contentOffset.y;
/* This is the percentage of the current offset / bottom offset. */
CGFloat percentage = offset / totalScroll;
/* When percentage = 0, the alpha should be 1 so we should flip the percentage. */
scrollView.alpha = (1.f - percentage);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3675 次 |
| 最近记录: |