zoukankan      html  css  js  c++  java
  • UIScrollView的偏移量

    // 建立一个滚动视图
    UIScrollView *scroView = [[UIScrollView alloc]initWithFrame: self.view.frame];
     
    // 滚动的尺寸 contentSize
    (如果不乘以图片的数量的话,这样只有一个位子)
    scrollView.contentSize = CGSizeMake(375*图片的数量,height)
     
    *****建立图片
    (图片的位置的宽度 * 图片的数量,不然所有的图片会叠加在一起)
    UIImageView *imageView = [[UIImageView alloc]initWithFrame:(WIDTH*图片的数量,Height, width,Height)];
     
     
    #######屏幕的偏移量
    -  (void) scrollViewDidenddelclerating
    {
       // 屏幕的偏移量
    CGfloat x = scrollView.contentOffset.x
     
    // 屏幕的宽
    CGfloat  w = CGRrectGetWidth(self.view.frame)
     
    // 偏移量除以宽,得到当前的页数
     
    NSInteger  curPage = x/w;
     
    // 根据tag 值找到对应的UIPageController
    UIPageController *pageController = (UIPageController *)[self.view viewWithTag:111];
     
    // 页面控制器当前的点 等于 偏移量 除以 当前的屏幕的宽度
    pageController . currentPage = curPage;
     
  • 相关阅读:
    法师 南邮NOJ网络赛2083
    法师 南邮NOJ网络赛2083
    法师 南邮NOJ网络赛2083
    水NOJ Duplicate Removal
    水NOJ Duplicate Removal
    水NOJ Duplicate Removal
    水NOJ Duplicate Removal
    【POJ】3630 Phone List
    【POJ】2503 Babelfish
    【POJ】1451 T9
  • 原文地址:https://www.cnblogs.com/wukun16/p/4847566.html
Copyright © 2011-2022 走看看