Karthikeyan Bose Karthikeyan Bose - 1 month ago 15
Swift Question

How to UIScrollView Indicator color cahnge?

When I use UIColor.blue its changing but when i try to apply RGB its not reflect in scrollview indicator.

func scrollViewDidScroll(_ scrollView: UIScrollView) {
let verticalIndicator: UIImageView = (scrollView.subviews[(scrollView.subviews.count - 1)] as! UIImageView)
verticalIndicator.backgroundColor = UIColor(red: 211/255, green: 138/255, blue: 252/255, alpha: 1)
// verticalIndicator.backgroundColor = UIColor.blue

}

Answer

I think problem is here

verticalIndicator.backgroundColor = UIColor(red: 211/255, green: 138/255, blue: 252/255, alpha: 1)

Change to

verticalIndicator.backgroundColor = UIColor(red: 211/255.0, green: 138/255.0, blue: 252/255.0, alpha: 1).

The result of division 211/255 is type of integer so it return only 0 or 1 (in this case i think it is 0).