UIScrollView with “Circular” scrolling

后端 未结 4 2088
挽巷
挽巷 2020-12-03 00:18

I am trying to make \"Circular\" scrolling in my UIScrollView, but unsuccessful.

What I want to do: if uiscrollview reaches end, it should move to start if uiscrollv

4条回答
  •  时光取名叫无心
    2020-12-03 00:38

    With reference from @redent84, find the code logic.

    override func viewWillAppear(_ animated: Bool)

    {
        super.viewWillAppear(animated)
    
        scrollView.contentSize = CGSize(width: scrollView.frame.width * CGFloat(imagesArray.count), height: scrollView.frame.height)
    
        scrollView.isPagingEnabled = true
    
        //        imagesArray.insert(imagesArray.last as? UIImage, at: 0)
        //        imagesArray.insert(imagesArray.first as? UIImage, at: imagesArray.count - 1)
    
    
        var testArr = ["A", "B", "C", "D"]
    
        let firstItem = testArr.first
        let lastItem = testArr.last
    
        testArr.insert(lastItem as! String, at: 0)
        testArr.append(firstItem as! String)
        print(testArr)
    
    
        for i in 0..

提交回复
热议问题