Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the initial page to be specified when setting image inputs #386

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@ open class FullScreenSlideshowViewController: UIViewController {
view.addSubview(slideshow)

// close button configuration
closeButton.setImage(UIImage(named: "ic_cross_white", in: Bundle(for: type(of: self)), compatibleWith: nil), for: UIControlState())
if #available(iOS 13.0, *) {
closeButton.setImage(UIImage(systemName: "xmark"), for: UIControl.State())
closeButton.tintColor = .white
} else {
closeButton.setImage(UIImage(named: "ic_cross_white", in: Bundle(for: type(of: self)), compatibleWith: nil), for: UIControlState())
}
closeButton.addTarget(self, action: #selector(FullScreenSlideshowViewController.close), for: UIControlEvents.touchUpInside)
view.addSubview(closeButton)
}
Expand Down
10 changes: 5 additions & 5 deletions ImageSlideshow/Classes/Core/ImageSlideshow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ open class ImageSlideshow: UIView {
}

/// reloads scroll view with latest slideshow items
func reloadScrollView() {
func reloadScrollView(initialPage: Int = 0) {
// remove previous slideshow items
for view in slideshowItems {
view.removeFromSuperview()
Expand All @@ -328,10 +328,10 @@ open class ImageSlideshow: UIView {
}

if circular && (scrollViewImages.count > 1) {
scrollViewPage = 1
scrollViewPage = initialPage + 1
scrollView.scrollRectToVisible(CGRect(x: scrollView.frame.size.width, y: 0, width: scrollView.frame.size.width, height: scrollView.frame.size.height), animated: false)
} else {
scrollViewPage = 0
scrollViewPage = initialPage
}

loadImages(for: scrollViewPage)
Expand Down Expand Up @@ -362,7 +362,7 @@ open class ImageSlideshow: UIView {
Set image inputs into the image slideshow
- parameter inputs: Array of InputSource instances.
*/
open func setImageInputs(_ inputs: [InputSource]) {
open func setImageInputs(_ inputs: [InputSource], initialPage: Int = 0) {
images = inputs
pageIndicator?.numberOfPages = inputs.count

Expand All @@ -383,7 +383,7 @@ open class ImageSlideshow: UIView {
scrollViewImages = images
}

reloadScrollView()
reloadScrollView(initialPage: initialPage)
layoutScrollView()
layoutPageControl()
setTimerIfNeeded()
Expand Down