Skip to content
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 @@ -25,6 +25,9 @@ open class FullScreenSlideshowViewController: UIViewController {
/// Close button
open var closeButton = UIButton()

/// Custom close button
open var closeButtonCustom: UIButton?

/// Close button frame
open var closeButtonFrame: CGRect?

Expand Down Expand Up @@ -71,8 +74,13 @@ 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 closeButtonCustom != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace by if let avoiding the force unwrapping

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the slow reply. Just to confirm, this should be:

if let custom_button = closeButtonCustom {
      closeButton = custom_button
}

Or something else?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if let closeButtonCustom = closeButtonCustom {
      closeButton = closeButtonCustom
}

This would be better to keep same names in if let and not have multiple different names

closeButton = closeButtonCustom!
} else {
// close button configuration
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
4 changes: 4 additions & 0 deletions ImageSlideshow/Classes/Core/ImageSlideshow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ open class ImageSlideshow: UIView {
/// Called on scrollViewDidEndDecelerating
open var didEndDecelerating: (() -> Void)?

/// Custom fullscreen close button
open var fullscreenCloseButton: UIButton?

/// Currenlty displayed slideshow item
open var currentSlideshowItem: ImageSlideshowItem? {
if slideshowItems.count > scrollViewPage {
Expand Down Expand Up @@ -543,6 +546,7 @@ open class ImageSlideshow: UIView {
self?.setCurrentPage(page, animated: false)
}

fullscreen.closeButtonCustom = fullscreenCloseButton
fullscreen.initialPage = currentPage
fullscreen.inputs = images
slideshowTransitioningDelegate = ZoomAnimatedTransitioningDelegate(slideshowView: self, slideshowController: fullscreen)
Expand Down