当前位置:   article > 正文

Swift UIScrollView滚动视图/无限循环滚动/自动滚动_swift scrollview无限滚动

swift scrollview无限滚动

之前用OC写了UIScrollView,这次用Swift写的,写的不好多担待,O(∩_∩)O~

                                        //先签一下协议
class ViewController: UIViewController , UIScrollViewDelegate {
   
  • 1
  • 2
  • 3
    //Swift没有宏定义,只好定义常量来代替宏定义
    let SCROLL_WIDTH = UIScreen.mainScreen().bounds.width
    let SCROLL_HEIGHT = UIScreen.mainScreen().bounds.height

    var scrollView :UIScrollView?     //轮播图
    var pageC :UIPageControl?         //小点
    var timer :NSTimer?               //定时器
    var scArray :NSMutableArray?      //图片数组
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.

        //图片数组
        scArray = ["5.jpg","0.jpg","1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","0.jpg"]

        //初始化轮播图
        scrollView = UIScrollView.init(frame: UIScreen.mainScr
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/你好赵伟/article/detail/780925
推荐阅读
相关标签
  

闽ICP备14008679号