zoukankan      html  css  js  c++  java
  • UIScrollView和 UIPageControl

     //建立UIScrollView

    前提是把UIScrollView设置成了属性,才能 self.scrollView

     //创建scrollView

        self.scrollView = [[[UIScrollView alloc] initWithFrame:[UIScreen mainScreen].bounds] autorelease];

        //  contentSize 决定了scrollView 滑动范围的大小

        self.scrollView.contentSize = CGSizeMake(7 * KScreeenWidth, KScreeenHeight);

        //是否显示水平方向滚动条

        self.scrollView.showsVerticalScrollIndicator = YES;

        //是否显示垂直方向的滚动条

    //    self.scrollView.showsHorizontalScrollIndicator = NO;

        //是否需要回弹效果

        self.scrollView.bounces = NO;

        //设置整页翻动

        self.scrollView.pagingEnabled = YES;

        //设置scrollView的偏移量, 默认是(0, 0);

    //    self.scrollView.contentOffset = CGPointMake(KScreeenWidth * 4, 0);

        //设置 scrollView 能否滚动

    //    self.scrollView.scrollEnabled = NO;

        [self addSubview:self.scrollView];

     

    //设置最大的缩放比例

        self.rootView.scrollView.maximumZoomScale = 5;

        //设置最小的缩放比例

        self.rootView.scrollView.minimumZoomScale = 0.5;

     

    //创建 UIPageControl

        self.pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(100, KScreeenHeight - 100, 120, 30)];

        //设置有多少个小点点的个数

        _pageControl.numberOfPages = 7;

        //改变整个小点点控件的颜色

        _pageControl.pageIndicatorTintColor = [UIColor magentaColor];

        //改变小点点的颜色

        self.pageControl.currentPageIndicatorTintColor = [UIColor greenColor];

        [self addSubview:_pageControl];

        [_pageControl release];

     

         // pageControl  添加事件

        [self.rootView.pageControl addTarget:self action:@selector(pagrAction:) forControlEvents:UIControlEventValueChanged];

     

     

     

  • 相关阅读:
    算法-经典趣题-寻找假银币
    一天一个 Linux 命令(3):cat 命令
    算法-经典趣题-青蛙过河
    常用数据库有哪些?
    SpringBoot2.0入门教程(一) 快速入门,项目构建HelloWorld示例
    一天一个 Linux 命令(2):ls 命令
    算法-经典趣题-爱因斯坦阶梯问题
    一天一个 Linux 命令(1):vim 命令
    什么是开发环境、测试环境、UAT环境、仿真环境、生产环境?
    算法-经典趣题-渔夫捕鱼
  • 原文地址:https://www.cnblogs.com/lhp-1992/p/4628400.html
Copyright © 2011-2022 走看看