ios Changing UIScrollView scrollbar color to different colors

后端 未结 17 2354
我在风中等你
我在风中等你 2020-12-05 07:16

How can we change color of UIScrollview\'s scroll indicator to something like blue, green etc.

I know we can change it to white, black. But other then these colors.

17条回答
  •  北海茫月
    2020-12-05 07:42

    Swift 2.0 :

    Add UIScrollView Delegate.

    func scrollViewDidScroll(scrollView: UIScrollView){
    let verticalIndicator: UIImageView = (scrollView.subviews[(scrollView.subviews.count - 1)] as! UIImageView)
    verticalIndicator.backgroundColor = UIColor.greenColor()
    
    let horizontalIndicator: UIImageView = (scrollView.subviews[(scrollView.subviews.count - 2)] as! UIImageView)
    horizontalIndicator.backgroundColor = UIColor.blueColor()
    }
    

提交回复
热议问题