An easy way to display multiple network images in a standard paging-scrollview style.
- Display images from specified URLs
- Custom Placeholder image - while the image is loading
- Show paging indicator while images are swiped
- Automatically adjust images to fit the scrollview
iOS 8.0+, Swift 3.0
Add into your Podfile.
pod "DTImageScrollView"
Then $ pod install
Drag a new view to your storyboard or interface builder. Change its class to DTImageScrollView.
In viewDidLoad()
, set the datasource
.
self.imageScrollView.datasource = self
Implement 3 datasource functions
func numberOfImages() -> Int {
return 3
}
func imageURL(index: Int) -> URL {
return NSURL(string: "http://www.boxzeed.com/wp-content/uploads/2015/09/1.1.3.jpg")!
}
func placeholderImageFor(index:Int) -> UIImage {
if index == 0 {
return UIImage(named: "sample")!
} else {
return UIImage(named: "placeholder")!
}
}
Call show()
to reload & display images
self.imageScrollView.show()
See more detail in the demo project
You can directly access and modify the scrollview propeties - scrollView
pageControl
placeholderImage
For example,
self.photosScrollView.pageControl.currentPageIndicatorTintColor = Utility.MAIN_RED_COLOR
self.photosScrollView.pageControl.pageIndicatorTintColor = UIColor.whiteColor()
Daron Tancharoen
- CONTACTS:
DTImageScrollView is licensed under the MIT License, please see the LICENSE file.