[ios]ScrollView中根据滚动距离来判断当前页数

来源:互联网 发布:机顶盒更改mac地址 编辑:程序博客网 时间:2024/05/22 05:14
  ScrollView中通过当前滚动的相对距离contentOffset属性除以页面宽度来获取当前页数,主要用于滚动视图时让导航栏按钮或标题同步切换;
</pre><pre name="code" class="objc">int page=(int)scrollView.contentOffset.x/kWidth+0.5;    UIButton *button=[self.view viewWithTag:page+100];    [button setSelected:YES];

0 0