alexhillc / AXPhotoViewer

An iOS/tvOS photo gallery viewer, useful for viewing a large (or small!) number of photos.
https://www.cocoacontrols.com/controls/axphotoviewer
MIT License
646 stars 119 forks source link

Added support of custom fade view for transition #36

Closed ashitikov closed 5 years ago

ashitikov commented 6 years ago

First of all, thank you for a great photo viewer library! In my case there is a need to change background color of viewer. I successfully did it with AXPhotosViewController, but AXPhotosTransitionController is internal of framework, and I had no access to it.

The changes in this pull request does not change protection level of AXPhotosTransitionController, but adds an ability to customize FadeView through AXTransitionInfo.

Also I think there is an option to rewrite fadeView property using lazy. What do u think?

alexhillc commented 6 years ago

Hey @ashitikov, sorry for the late response!

I think you're right in that there is room for customization with the fadeView. I like the idea of having a closure that will serve as an initializer. Maybe something like this:

@objc class AXTransitionInfo: NSObject {
// ...
  /// The fading backdrop that is displayed while the photo viewer is presenting/dismissing.  
  @objc public var fadingBackdropView: (() -> UIView) = {
      let view = UIView()
      view.backgroundColor = .black
      return view
  }
// ...
}

This way, the fade view is entirely customizable if the developer wants to do something fun like add a UIVisualEffectView as a backdrop.