### Install ImageSlideshow with CocoaPods Source: https://context7.com/zvonicek/imageslideshow/llms.txt Add ImageSlideshow and desired input-source subspecs to your Podfile for installation. ```ruby # Podfile # Core only pod 'ImageSlideshow', '~> 1.9.0' # Core + Alamofire remote image loading pod 'ImageSlideshow/Alamofire', '~> 1.9.0' # Core + SDWebImage remote image loading pod 'ImageSlideshow/SDWebImage', '~> 1.9.0' # Core + Kingfisher remote image loading pod 'ImageSlideshow/Kingfisher', '~> 1.9.0' # Core + AFNetworking remote image loading pod 'ImageSlideshow/AFURL', '~> 1.9.0' # Core + Parse file image loading pod 'ImageSlideshow/Parse', '~> 1.9.0' ``` -------------------------------- ### Install ImageSlideshow with Carthage Source: https://context7.com/zvonicek/imageslideshow/llms.txt Add the ImageSlideshow dependency to your Cartfile for installation. ```ruby # Cartfile github "zvonicek/ImageSlideshow" ~> 1.9.0 ``` -------------------------------- ### Implement Custom InputSource with Nuke Source: https://context7.com/zvonicek/imageslideshow/llms.txt Implement the `InputSource` protocol to integrate custom image loading mechanisms. This example shows how to use the Nuke library for loading images. ```swift import UIKit import ImageSlideshow import Nuke // hypothetical third-party loader /// Custom InputSource backed by the Nuke image loading pipeline class NukeSource: NSObject, InputSource { let url: URL let placeholder: UIImage? init(url: URL, placeholder: UIImage? = nil) { self.url = url self.placeholder = placeholder } func load(to imageView: UIImageView, with callback: @escaping (UIImage?) -> Void) { // Show placeholder immediately while loading imageView.image = placeholder let request = ImageRequest(url: url) Nuke.loadImage(with: request, into: imageView) { switch result { case .success(let response): callback(response.image) case .failure: callback(self.placeholder) } } } func cancelLoad(on imageView: UIImageView) { Nuke.cancelRequest(for: imageView) } } // Usage slideshow.setImageInputs([ NukeSource(url: URL(string: "https://example.com/photo.jpg")!, placeholder: UIImage(named: "loading")), ]) ``` -------------------------------- ### Install ImageSlideshow with CocoaPods Source: https://github.com/zvonicek/imageslideshow/blob/master/README.md Add this line to your Podfile to install the ImageSlideshow library using CocoaPods. ```ruby pod 'ImageSlideshow', '~> 1.9.0' ``` -------------------------------- ### Install ImageSlideshow with Swift Package Manager Source: https://context7.com/zvonicek/imageslideshow/llms.txt Add the ImageSlideshow package to your project's dependencies in Package.swift. ```swift // Package.swift dependencies: [ .package(url: "https://github.com/zvonicek/ImageSlideshow.git", from: "1.9.2") ] ``` -------------------------------- ### Implement Custom Page Indicator Source: https://context7.com/zvonicek/imageslideshow/llms.txt Create a custom page indicator by conforming to the `PageIndicatorView` protocol. This example shows a `DashPageIndicator` using `UIStackView`. ```swift class DashPageIndicator: UIStackView, PageIndicatorView { var view: UIView { return self } var numberOfPages: Int = 0 { didSet { rebuild() } } var page: Int = 0 { didSet { highlight() } } private func rebuild() { arrangedSubviews.forEach { $0.removeFromSuperview() } for _ in 0.. ActivityIndicatorView { return PulsingDot() } } slideshow.activityIndicator = PulsingDotFactory() ``` -------------------------------- ### Initialize and Configure ImageSlideshow View Source: https://context7.com/zvonicek/imageslideshow/llms.txt Demonstrates how to create, layout, and configure the ImageSlideshow view in code, including setting behavior, preloading strategy, and callbacks. ```swift import UIKit import ImageSlideshow class GalleryViewController: UIViewController { // Option A: create in code let slideshow = ImageSlideshow() // Option B: wire via Interface Builder // @IBOutlet var slideshow: ImageSlideshow! override func viewDidLoad() { super.viewDidLoad() // --- Layout (code-only path) --- slideshow.frame = CGRect(x: 0, y: 0, width: view.bounds.width, height: 260) view.addSubview(slideshow) // --- Behavior --- slideshow.slideshowInterval = 3.5 // auto-advance every 3.5 s (0 = disabled) slideshow.circular = true // infinite looping (default: true) slideshow.zoomEnabled = true // pinch-to-zoom slideshow.maximumScale = 3.0 // max zoom multiplier (default: 2.0) slideshow.draggingEnabled = true // allow manual swiping (default: true) slideshow.contentScaleMode = .scaleAspectFill // --- Preloading strategy --- slideshow.preload = .fixed(offset: 1) // only load ±1 images around current page // slideshow.preload = .all // preload everything (default) // --- Callbacks --- slideshow.currentPageChanged = { page in print("Moved to page \(page)") } slideshow.willBeginDragging = { print("User started dragging") } slideshow.didEndDecelerating = { print("Scroll deceleration ended") } // --- Delegate (alternative to closures) --- slideshow.delegate = self // --- Load images --- slideshow.setImageInputs([ BundleImageSource(imageString: "banner1"), BundleImageSource(imageString: "banner2"), BundleImageSource(imageString: "banner3"), ]) } } extension GalleryViewController: ImageSlideshowDelegate { func imageSlideshow(_ imageSlideshow: ImageSlideshow, didChangeCurrentPageTo page: Int) { print("Delegate: current page is now \(page)") } func imageSlideshowWillBeginDragging(_ imageSlideshow: ImageSlideshow) { } func imageSlideshowDidEndDecelerating(_ imageSlideshow: ImageSlideshow) { } } ``` -------------------------------- ### Manual Instantiation of Full-Screen Slideshow Source: https://context7.com/zvonicek/imageslideshow/llms.txt Manually instantiate and configure a `FullScreenSlideshowViewController` for complete control over its presentation and behavior. Ensure to sync the page selection back to the inline slideshow when the user closes the full-screen view. ```swift @objc func openFullScreenManual() { let fsVC = FullScreenSlideshowViewController() fsVC.inputs = slideshow.images // pass current input sources fsVC.initialPage = slideshow.currentPage // start on the same slide fsVC.backgroundColor = UIColor.black fsVC.closeButtonFrame = CGRect(x: 16, y: 44, width: 44, height: 44) // Sync page back to the inline slideshow when user closes fsVC.pageSelected = { [weak self] page in self?.slideshow.setCurrentPage(page, animated: false) } let transitionDelegate = ZoomAnimatedTransitioningDelegate( slideshowView: slideshow, slideshowController: fsVC ) slideshow.slideshowTransitioningDelegate = transitionDelegate fsVC.transitioningDelegate = transitionDelegate fsVC.modalPresentationStyle = .custom present(fsVC, animated: true) } ``` -------------------------------- ### InputSource Protocol Source: https://context7.com/zvonicek/imageslideshow/llms.txt Implement the InputSource protocol to integrate custom image loading mechanisms not covered by the built-in subspecs. ```APIDOC ## `InputSource` Protocol — Custom Image Sources Implement `InputSource` to integrate any image loading mechanism not covered by the built-in subspecs. ```swift import UIKit import ImageSlideshow import Nuke // hypothetical third-party loader /// Custom InputSource backed by the Nuke image loading pipeline class NukeSource: NSObject, InputSource { let url: URL let placeholder: UIImage? init(url: URL, placeholder: UIImage? = nil) { self.url = url self.placeholder = placeholder } func load(to imageView: UIImageView, with callback: @escaping (UIImage?) -> Void) { // Show placeholder immediately while loading imageView.image = placeholder let request = ImageRequest(url: url) Nuke.loadImage(with: request, into: imageView) { result in switch result { case .success(let response): callback(response.image) case .failure: callback(self.placeholder) } } } func cancelLoad(on imageView: UIImageView) { Nuke.cancelRequest(for: imageView) } } // Usage slideshow.setImageInputs([ NukeSource(url: URL(string: "https://example.com/photo.jpg")!, placeholder: UIImage(named: "loading")), ]) ``` ``` -------------------------------- ### `presentFullScreenController(from:completion:)` — Full-Screen Viewer Source: https://context7.com/zvonicek/imageslideshow/llms.txt Presents a full-screen modal slideshow with zoom and interactive dismissal, synchronized with the inline slideshow. ```APIDOC ## `presentFullScreenController(from:completion:)` — Full-Screen Viewer ### Description Present a full-screen modal slideshow (zoom-enabled, black background, interactive dismiss) that stays in sync with the inline slideshow. ### Method - `presentFullScreenController(from: UIViewController, completion: (() -> Void)?) -> FullScreenSlideshowViewController` ### Parameters #### Path Parameters - `from` (UIViewController) - The view controller from which to present the full-screen slideshow. - `completion` (Optional closure) - A closure to be executed after the full-screen slideshow is presented. ### Request Example ```swift let fullScreenVC = slideshow.presentFullScreenController(from: self) { print("Full screen presented") } // Customize the full-screen slideshow independently fullScreenVC.slideshow.activityIndicator = DefaultActivityIndicator(style: .white, color: nil) ``` ### Response #### Success Response - Returns `FullScreenSlideshowViewController` - The presented full-screen slideshow view controller. ``` -------------------------------- ### Present Full-Screen Slideshow with Tap Gesture Source: https://context7.com/zvonicek/imageslideshow/llms.txt Set up a tap gesture recognizer to present a full-screen slideshow. The `presentFullScreenController` method returns the `FullScreenSlideshowViewController` for further customization. ```swift override func viewDidLoad() { super.viewDidLoad() let tap = UITapGestureRecognizer(target: self, action: #selector(openFullScreen)) slideshow.addGestureRecognizer(tap) } @objc func openFullScreen() { // presentFullScreenController returns the FullScreenSlideshowViewController let fullScreenVC = slideshow.presentFullScreenController(from: self) { print("Full screen presented") } // Customize the full-screen slideshow independently fullScreenVC.slideshow.activityIndicator = DefaultActivityIndicator(style: .white, color: nil) } ``` -------------------------------- ### Integrate ImageSlideshow with Carthage Source: https://github.com/zvonicek/imageslideshow/blob/master/README.md Specify ImageSlideshow in your Cartfile to integrate it into your Xcode project using Carthage. ```ruby github "zvonicek/ImageSlideshow" ~> 1.9.0 ``` -------------------------------- ### setCurrentPage(_:animated:) / nextPage(animated:) / previousPage(animated:) Source: https://context7.com/zvonicek/imageslideshow/llms.txt Allows for programmatic navigation to advance or jump to any slide without requiring user interaction. ```APIDOC ## `setCurrentPage(_:animated:)` / `nextPage(animated:)` / `previousPage(animated:)` — Programmatic Navigation Advance or jump to any slide without user interaction. ```swift // Jump directly to slide index 2 (zero-based), no animation slideshow.setCurrentPage(2, animated: false) // Animate forward to the next slide (respects circular setting) slideshow.nextPage(animated: true) // Animate backward to the previous slide slideshow.previousPage(animated: true) // Read the currently visible page index let current = slideshow.currentPage // Int, read-only // Pause and resume the auto-advance timer manually slideshow.pauseTimer() slideshow.unpauseTimer() ``` ``` -------------------------------- ### Present Full Screen Slideshow Source: https://github.com/zvonicek/imageslideshow/blob/master/README.md Add a tap gesture recognizer to the slideshow view and implement a tap handler function to present the FullScreenSlideshowViewController. ```swift override func viewDidLoad() { let gestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(ViewController.didTap)) slideshow.addGestureRecognizer(gestureRecognizer) } func didTap() { slideshow.presentFullScreenController(from: self) } ``` -------------------------------- ### Configure Default Activity Indicator Source: https://context7.com/zvonicek/imageslideshow/llms.txt Use `DefaultActivityIndicator` to display a loading spinner. You can choose between a default gray style, a white style recommended for dark backgrounds, or a custom tinted spinner. ```swift slideshow.activityIndicator = DefaultActivityIndicator() ``` ```swift slideshow.activityIndicator = DefaultActivityIndicator(style: .white, color: nil) ``` ```swift slideshow.activityIndicator = DefaultActivityIndicator(style: .gray, color: .systemBlue) ``` -------------------------------- ### ImageSlideshowDelegate for Event Handling Source: https://context7.com/zvonicek/imageslideshow/llms.txt Implement the `ImageSlideshowDelegate` protocol to receive events such as page changes, and to control the slideshow's timer during user interaction. Ensure the delegate is set on the `ImageSlideshow` instance. ```swift class HomeViewController: UIViewController, ImageSlideshowDelegate { let slideshow = ImageSlideshow() override func viewDidLoad() { super.viewDidLoad() slideshow.delegate = self slideshow.setImageInputs([ BundleImageSource(imageString: "slide1"), BundleImageSource(imageString: "slide2"), ]) } // Called every time the visible page changes func imageSlideshow(_ imageSlideshow: ImageSlideshow, didChangeCurrentPageTo page: Int) { navigationItem.title = "Photo \(page + 1) of \(imageSlideshow.images.count)" } // Called when the user starts dragging func imageSlideshowWillBeginDragging(_ imageSlideshow: ImageSlideshow) { imageSlideshow.pauseTimer() } // Called when the scroll view finishes decelerating func imageSlideshowDidEndDecelerating(_ imageSlideshow: ImageSlideshow) { imageSlideshow.unpauseTimer() } } ``` -------------------------------- ### Load Images into ImageSlideshow Source: https://github.com/zvonicek/imageslideshow/blob/master/README.md Set images for the ImageSlideshow using the `setImageInputs` method. Supports various `InputSource` types like `ImageSource`, `AlamofireSource`, `KingfisherSource`, and `ParseSource`. ```swift slideshow.setImageInputs([ ImageSource(image: UIImage(named: "myImage"))!, ImageSource(image: UIImage(named: "myImage2"))!, AlamofireSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080"), KingfisherSource(urlString: "https://images.unsplash.com/photo-1432679963831-2dab49187847?w=1080"), ParseSource(file: PFFile(name:"image.jpg", data:data)) ]) ``` -------------------------------- ### Use Label Page Indicator Source: https://github.com/zvonicek/imageslideshow/blob/master/README.md Set the pageIndicator to a LabelPageIndicator for a "current/total" page count display. ```swift slideshow.pageIndicator = LabelPageIndicator() ``` -------------------------------- ### Enable Default Activity Indicator Source: https://github.com/zvonicek/imageslideshow/blob/master/README.md Set the activityIndicator property to a DefaultActivityIndicator instance to show a loading indicator. This is disabled by default. ```swift slideshow.activityIndicator = DefaultActivityIndicator() ``` -------------------------------- ### Programmatic Navigation for ImageSlideshow Source: https://context7.com/zvonicek/imageslideshow/llms.txt Control the slideshow's current page programmatically using methods like `setCurrentPage`, `nextPage`, and `previousPage`. You can also pause and resume the auto-advance timer. ```swift // Jump directly to slide index 2 (zero-based), no animation slideshow.setCurrentPage(2, animated: false) // Animate forward to the next slide (respects circular setting) slideshow.nextPage(animated: true) // Animate backward to the previous slide slideshow.previousPage(animated: true) // Read the currently visible page index let current = slideshow.currentPage // Int, read-only // Pause and resume the auto-advance timer manually slideshow.pauseTimer() slideshow.unpauseTimer() ``` -------------------------------- ### Hide Page Indicator Source: https://context7.com/zvonicek/imageslideshow/llms.txt Set the page indicator to `nil` to hide it entirely. ```swift slideshow.pageIndicator = nil ``` -------------------------------- ### setImageInputs(_:) Source: https://context7.com/zvonicek/imageslideshow/llms.txt Replaces the current set of slides with a new array of InputSource objects. This action reloads the scroll view, resets the timer, and repositions the page indicator. ```APIDOC ## `setImageInputs(_:)` — Loading Images Replaces the current set of slides with a new array of `InputSource` objects. Calling this method reloads the scroll view, resets the timer, and repositions the page indicator. ```swift // Mix any combination of input source types in one call slideshow.setImageInputs([ // Local UIImage ImageSource(image: UIImage(named: "hero")!), // Bundle asset by name BundleImageSource(imageString: "thumbnail"), // File on disk FileImageSource(path: NSHomeDirectory() + "/Documents/photo.jpg"), // Remote via Alamofire (pod 'ImageSlideshow/Alamofire') AlamofireSource(urlString: "https://example.com/image1.jpg", placeholder: UIImage(named: "placeholder"))!, // Remote via SDWebImage (pod 'ImageSlideshow/SDWebImage') SDWebImageSource(urlString: "https://example.com/image2.jpg", placeholder: UIImage(named: "placeholder"))!, // Remote via Kingfisher with options (pod 'ImageSlideshow/Kingfisher') KingfisherSource(urlString: "https://example.com/image3.jpg", placeholder: UIImage(named: "placeholder"), options: [.transition(.fade(0.3))])!, // Remote via AFNetworking (pod 'ImageSlideshow/AFURL') AFURLSource(urlString: "https://example.com/image4.jpg", placeholder: UIImage(named: "placeholder"))!, ]) ``` ``` -------------------------------- ### Load Various Image Inputs Source: https://context7.com/zvonicek/imageslideshow/llms.txt Use `setImageInputs` to replace the current slides with a new array of `InputSource` objects. This method reloads the scroll view, resets the timer, and repositions the page indicator. ```swift slideshow.setImageInputs([ // Local UIImage ImageSource(image: UIImage(named: "hero")!), // Bundle asset by name BundleImageSource(imageString: "thumbnail"), // File on disk FileImageSource(path: NSHomeDirectory() + "/Documents/photo.jpg"), // Remote via Alamofire (pod 'ImageSlideshow/Alamofire') AlamofireSource(urlString: "https://example.com/image1.jpg", placeholder: UIImage(named: "placeholder"))!, // Remote via SDWebImage (pod 'ImageSlideshow/SDWebImage') SDWebImageSource(urlString: "https://example.com/image2.jpg", placeholder: UIImage(named: "placeholder"))!, // Remote via Kingfisher with options (pod 'ImageSlideshow/Kingfisher') KingfisherSource(urlString: "https://example.com/image3.jpg", placeholder: UIImage(named: "placeholder"), options: [.transition(.fade(0.3))])!, // Remote via AFNetworking (pod 'ImageSlideshow/AFURL') AFURLSource(urlString: "https://example.com/image4.jpg", placeholder: UIImage(named: "placeholder"))!, ]) ``` -------------------------------- ### `ImageSlideshowDelegate` — Event Delegation Source: https://context7.com/zvonicek/imageslideshow/llms.txt Protocol for receiving slideshow events, such as page changes and drag gestures. ```APIDOC ## `ImageSlideshowDelegate` — Event Delegation ### Description Receive slideshow events via delegate methods as an alternative (or complement) to closure callbacks. ### Delegate Methods - `imageSlideshow(_:didChangeCurrentPageTo:)` - Called every time the visible page changes. - Parameters: - `imageSlideshow`: The ImageSlideshow instance. - `page`: The new current page index. - `imageSlideshowWillBeginDragging(_:)` - Called when the user starts dragging the slideshow. - Parameters: - `imageSlideshow`: The ImageSlideshow instance. - `imageSlideshowDidEndDecelerating(_:)` - Called when the scroll view finishes decelerating after a drag. - Parameters: - `imageSlideshow`: The ImageSlideshow instance. ### Request Example ```swift class HomeViewController: UIViewController, ImageSlideshowDelegate { let slideshow = ImageSlideshow() override func viewDidLoad() { super.viewDidLoad() slideshow.delegate = self slideshow.setImageInputs([ BundleImageSource(imageString: "slide1"), BundleImageSource(imageString: "slide2"), ]) } // Called every time the visible page changes func imageSlideshow(_ imageSlideshow: ImageSlideshow, didChangeCurrentPageTo page: Int) { navigationItem.title = "Photo \(page + 1) of \(imageSlideshow.images.count)" } // Called when the user starts dragging func imageSlideshowWillBeginDragging(_ imageSlideshow: ImageSlideshow) { imageSlideshow.pauseTimer() } // Called when the scroll view finishes decelerating func imageSlideshowDidEndDecelerating(_ imageSlideshow: ImageSlideshow) { imageSlideshow.unpauseTimer() } } ``` ``` -------------------------------- ### Customize Default Activity Indicator Style Source: https://github.com/zvonicek/imageslideshow/blob/master/README.md Customize the appearance of the DefaultActivityIndicator by specifying its style and color. ```swift slideshow.activityIndicator = DefaultActivityIndicator(style: .white, color: nil) ``` -------------------------------- ### Configure Page Indicator Position Source: https://github.com/zvonicek/imageslideshow/blob/master/README.md Set the pageIndicatorPosition to customize both horizontal and vertical placement of the page indicator. Padding can be specified for left/right horizontal positions and custom vertical positions. ```swift slideshow.pageIndicatorPosition = PageIndicatorPosition(horizontal: .left(padding: 20), vertical: .bottom) ``` -------------------------------- ### Customize Page Indicator with UIPageControl Source: https://context7.com/zvonicek/imageslideshow/llms.txt Replace the default page indicator with a styled UIPageControl. The `withSlideshowColors()` helper adapts to dark mode automatically. You can also manually style a UIPageControl or use a `LabelPageIndicator` for a numeric display. ```swift let dots = UIPageControl.withSlideshowColors() // adapts to dark mode automatically slideshow.pageIndicator = dots ``` ```swift let pageControl = UIPageControl() pageControl.currentPageIndicatorTintColor = .white pageControl.pageIndicatorTintColor = UIColor.white.withAlphaComponent(0.4) slideshow.pageIndicator = pageControl ``` ```swift slideshow.pageIndicator = LabelPageIndicator() ``` -------------------------------- ### Control Page Indicator Position Source: https://context7.com/zvonicek/imageslideshow/llms.txt Adjust the position of the page indicator using `PageIndicatorPosition` with options for horizontal and vertical alignment, including padding and relative positioning. ```swift slideshow.pageIndicatorPosition = PageIndicatorPosition(horizontal: .center, vertical: .bottom) ``` ```swift slideshow.pageIndicatorPosition = PageIndicatorPosition(horizontal: .left(padding: 16), vertical: .under) ``` ```swift slideshow.pageIndicatorPosition = PageIndicatorPosition(horizontal: .right(padding: 12), vertical: .top) ``` ```swift slideshow.pageIndicatorPosition = PageIndicatorPosition( horizontal: .center, vertical: .customBottom(padding: 8) // 8 pt above the bottom edge ) ``` -------------------------------- ### Customize Page Indicator with UIPageControl Source: https://github.com/zvonicek/imageslideshow/blob/master/README.md Assign a custom UIPageControl to the slideshow's pageIndicator property to change its appearance. Set the current and default page indicator colors. ```swift let pageIndicator = UIPageControl() pageIndicator.currentPageIndicatorTintColor = UIColor.lightGray pageIndicator.pageIndicatorTintColor = UIColor.black slideshow.pageIndicator = pageIndicator ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.