https://github.com/mosheberman/customscrollindicator
A quick demo project demonstrating how to customize UIScrollView's scroll indicators.
https://github.com/mosheberman/customscrollindicator
Last synced: 2 months ago
JSON representation
A quick demo project demonstrating how to customize UIScrollView's scroll indicators.
- Host: GitHub
- URL: https://github.com/mosheberman/customscrollindicator
- Owner: MosheBerman
- License: mit
- Created: 2016-03-22T14:23:24.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-03-22T14:29:53.000Z (over 10 years ago)
- Last Synced: 2026-01-02T03:39:16.462Z (6 months ago)
- Language: Swift
- Size: 15.6 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CustomScrollViewIndicators
This project demonstrates how to customize UIScrollView indicator insets.
How It Works:
---
UIScrollView uses UIImages for displaying scroll indicators. So, we can use the tintColor property along with `UIImageModeAlwaysTemplate` to change the color of the bars.
Implementation:
---
The sample implementation, in Swift 2.2, below.
```
// MARK: - Color the Scroll View
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()
}
```
Some thoughts:
---
- The method for finding the scroll indicator images might break if the internal implementation changes.
- The project has a pretty neat sorting technique for ensuring that the color names appear in the correct order.
- I've successfully submitted an app to the App Store with this code included, butyour mileage may vary.
License:
---
MIT