ios Changing UIScrollView scrollbar color to different colors

后端 未结 17 2436
我在风中等你
我在风中等你 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:41

    Try this it would certainly help you

        for ( UIView *view in scrollBar.subviews ) {
    
           if (view.tag == 0 && [view isKindOfClass:UIImageView.class])
           {
            UIImageView *imageView      = (UIImageView *)view;
            imageView.backgroundColor   = [UIColor yellowColor];
           }
        }
    

    Explanation: UIScrollBar is a collection of subviews. Here scrollBar indicator(vertical/horizontal) is the one of the subviews and it's an UIImageView.So if we set custom color to the UIImageView it effects scrollBar Indicator.

提交回复
热议问题