Easy and customizable Swift image slider with lazy loading images and full screen viewer
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
UISliderView into your Xcode project using CocoaPods, specify it in your
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '11.0' use_frameworks! target '<Your Target Name>' do pod 'UISliderView', '~> 1.0.6' end
Then, run the following terminal command in project directory:
$ pod install
For use The Swift Package Manager you need add
UISliderView dependency to
import PackageDescription let package = Package( name: "PROJECT_NAME", targets: , dependencies: [ .package(url: "https://github.com/AlekseyPleshkov/UISliderView.git", from: "1.0.6") ] )
UISliderView to your targets dependencies:
.target( name: "TARGET_NAME", dependencies: [ "UISliderView", ] ),
And run terminal command:
swift package update
Or use SPM in XCode 😊
Import package in your file
UISliderView class to custom class for empty view or create
UISliderView class programmably.
@IBOutlet weak var sliderView: UISliderView! // or let sliderView = UISliderView()
Set list of image urls to
sliderView and run
reloadData() method for create/reload slides with images
sliderView.images = [ URL(string: "https://source.unsplash.com/1024x1024")!, URL(string: "https://source.unsplash.com/1024x1024")!, URL(string: "https://source.unsplash.com/1024x1024")!, URL(string: "https://source.unsplash.com/1024x1024")! ] sliderView.reloadData()
delegate: UISliderViewDelegate?. The object that acts as the delegate of the slider view. Notifies at main events.
viewController: UIViewController?. View controller for show full screen slider. Set this parameter to open slider in full screen.
images: [URL]. List of image urls for loading and showing in sliders.
imageContentMode: UIView.ContentMode = .scaleAspectFill. Image content mode for slide.
activityIndicatorColor: UIColor = .black. Activity indicator color (while the image is loading).
activityIndicatorStyle: UIActivityIndicatorView.Style?. /// Activity indicator style (while the image is loading).
pageIndicatorColor: UIColor?. Page indicator color.
pageCurrentIndicatorColor: UIColor?. Current page indicator color.
fullScreenImageContentMode: UIView.ContentMode = .scaleAspectFill. Image content mode for full screen slide.
fullScreenActivityIndicatorColor: UIColor = .white. Activity indicator color (while the image is loading) for full screen slide.
fullScreenActivityIndicatorStyle: UIActivityIndicatorView.Style?. /// Activity indicator style (while the image is loading) for full screen slide.
fullScreenBackButtonImage: UIImage?. Image for back button in full screen mode. Automatically hidden button if image not set.
isShowPageControl: Bool = true. Shows pageControl indicator.
reloadData(). Reloads slides by list of url images. Call this method after set list of urls to image parameter.
sliderView(_ sliderView: UISliderView, didChangeSlideAt index: Int). Tells the delegate that the slide did change.
sliderView(_ sliderView: UISliderView, didChangeFullScreenVisible isVisible: Bool). Tells the delegate that the full screen view did change visible state.
UISliderView is released under the MIT license. In short, it's royalty-free but you must keep the copyright notice in your code or software distribution.