SwapperView
public class SwapperView<ViewID> : UIView where ViewID : CustomStringConvertible, ViewID : Hashable
View that is able to swap between 1+ child views.
-
Override
defaultConfig
for this once instance.Declaration
Swift
public var config: SwapperViewConfig { get set }
-
Remove all of the previous swapping views and set new ones.
Declaration
Swift
public func setSwappingViews(_ newSwappingViews: [(ViewID, SwappableView)], swapTo: ViewID?)
-
Reference the currently shown view, if it’s set.
Declaration
Swift
public private(set) var currentView: (ViewID, SwapperWeakView)? { get }
-
All of the views that have been added to this
SwapperView
.Note
Seeself.setSwappingViews()
to set this.Declaration
Swift
public private(set) var swappingViews: [ViewID : SwapperWeakView] { get }
-
Remove the old view that was shown before and show the new view to the screen.
Throws
SwapperError.viewToSwapToNotAdded
If theviewIndicator
is not found inself.swappingViews
.Throws
SwapperError.viewToSwapToNoLongerExists
If theviewIndicator
no longer exists. Probably garbage collected.Declaration
Swift
public func swapTo(_ viewIndicator: ViewID, animate: Bool = true, onComplete: (() -> Void)?) throws
Parameters
viewIndicator
View from
self.swappingViews
to swap to.animate
To animate or not.
onComplete
Optional parameter to tell you when the swap animation is complete and the new view is shown.