如何更改 UIScrollView 指示器颜色? [英] How to change UIScrollView Indicator color?

查看:34
本文介绍了如何更改 UIScrollView 指示器颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 UIColor.blue 时,它会改变,但是当我尝试应用 RGB 时,它不会反映在滚动视图指示器中.

When I use UIColor.blue its changing, but when I try to apply RGB, its not reflected 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

}

推荐答案

我觉得问题出在这里

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

改为

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

除法 211/255 的结果是整数类型,所以它只返回 0 或 1(在这种情况下我认为它是 0).

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).

这篇关于如何更改 UIScrollView 指示器颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆