0

I want to change the color of horizontal scroll bar Indicator of UICollectionView, Apart from default, black or white which could be done in storyboard?

niket
  • 27
  • 1
  • 7
  • 3
    see this once http://stackoverflow.com/questions/12005187/ios-changing-uiscrollview-scrollbar-color-to-different-colors – Anbu.Karthik Aug 08 '16 at 10:30
  • Please specify the language in which you wanted to use i.e swift or objective C . I saw somebody answered but they have the confusion. So please write whole content for your question. – ManiaChamp Aug 08 '16 at 10:55

2 Answers2

1

Please refer the below code for the Scrolling UICollection View Horizontal Bar color change also refer below link for more information and download sample code from that.

http://blog.mosheberman.com/coloring-the-ios-uiscrollviewindicators/

func setScrollIndicatorColor(color: UIColor) {

            for view in self.tableView.subviews {
                if view.isKindOfClass(UIImageView.self),
                    let imageView = view as? UIImageView,
                    let image = imageView.image  {

                    imageView.tintColor = color
                    imageView.image = image.imageWithRenderingMode(.AlwaysTemplate)
                }
            }

            self.tableView.flashScrollIndicators()
        }
ashmi123
  • 710
  • 1
  • 6
  • 21
0

You can use delegate method : 'scrollViewDidScroll' and add

//get refrence of vertical indicator

UIImageView *verticalIndicator = ((UIImageView *)[scrollView.subviews objectAtIndex:(scrollView.subviews.count-1)]);
//set color to vertical indicator
[verticalIndicator setBackgroundColor:[UIColor redColor]];


//get refrence of horizontal indicator

UIImageView *horizontalIndicator = ((UIImageView *)[scrollView.subviews objectAtIndex:(scrollView.subviews.count-2)]);
//set color to horizontal indicator
[horizontalIndicator setBackgroundColor:[UIColor blueColor]];
Maulik Pandya
  • 2,200
  • 17
  • 26