HeroModifier
public final class HeroModifier
Undocumented
-
Undocumented
Declaration
Swift
public init(applyFunction:@escaping (inout HeroTargetState) -> Void)
-
Apply modifiers directly to the view at the start of the transition. The modifiers supplied here won’t be animated. For source views, modifiers are set directly at the beginning of the animation. For destination views, they replace the target state (final appearance).
Declaration
Swift
public static func beginWith(_ modifiers: [HeroModifier]) -> HeroModifier
-
Undocumented
Declaration
Swift
public static func beginWith(modifiers: [HeroModifier]) -> HeroModifier
-
Undocumented
Declaration
Swift
public static func beginWith(_ modifiers: HeroModifier...) -> HeroModifier
-
Use global coordinate space.
When using global coordinate space. The view become a independent view that is not a subview of any view. It won’t move when its parent view moves, and won’t be affected by parent view’s attributes.
When a view is matched, this is automatically enabled. The
source
modifier will also enable this.Global coordinate space is default for all views prior to version 0.1.3
Declaration
Swift
public static var useGlobalCoordinateSpace: HeroModifier
-
ignore all heroModifiers attributes for a view’s direct subviews.
Declaration
Swift
public static var ignoreSubviewModifiers: HeroModifier
-
ignore all heroModifiers attributes for a view’s subviews.
- recursive: if false, will only ignore direct subviews’ modifiers. default false.
Declaration
Swift
public static func ignoreSubviewModifiers(recursive: Bool = false) -> HeroModifier
-
Will create snapshot optimized for different view type. For custom views or views with masking, useOptimizedSnapshot might create snapshots that appear differently than the actual view. In that case, use .useNormalSnapshot or .useSlowRenderSnapshot to disable the optimization.
This modifier actually does nothing by itself since .useOptimizedSnapshot is the default.
Declaration
Swift
public static var useOptimizedSnapshot: HeroModifier
-
Create snapshot using snapshotView(afterScreenUpdates:).
Declaration
Swift
public static var useNormalSnapshot: HeroModifier
-
Create snapshot using layer.render(in: currentContext). This is slower than .useNormalSnapshot but gives more accurate snapshot for some views (eg. UIStackView).
Declaration
Swift
public static var useLayerRenderSnapshot: HeroModifier
-
Force Hero to not create any snapshot when animating this view. This will mess up the view hierarchy, therefore, view controllers have to rebuild its view structure after the transition finishes.
Declaration
Swift
public static var useNoSnapshot: HeroModifier
-
Force the view to animate.
By default, Hero will not animate if the view is outside the screen bounds or if there is no animatable hero modifier, unless this modifier is used.
Declaration
Swift
public static var forceAnimate: HeroModifier
-
Force Hero use scale based size animation. This will convert all .size modifier into .scale modifier. This is to help Hero animate layers that doesn’t support bounds animation. Also gives better performance.
Declaration
Swift
public static var useScaleBasedSizeChange: HeroModifier
-
Undocumented
Declaration
Swift
public static func from(node: ExprNode) -> HeroModifier?
-
Fade the view during transition
Declaration
Swift
public static var fade: HeroModifier
-
Force don’t fade view during transition
Declaration
Swift
public static var forceNonFade: HeroModifier
-
Set the position for the view to animate from/to.
Declaration
Swift
public static func position(_ position: CGPoint) -> HeroModifier
Parameters
position
position for the view to animate from/to
-
Set the size for the view to animate from/to.
Declaration
Swift
public static func size(_ size: CGSize) -> HeroModifier
Parameters
size
size for the view to animate from/to
-
Set the transform for the view to animate from/to. Will override previous perspective, scale, translate, & rotate modifiers
Declaration
Swift
public static func transform(_ t: CATransform3D) -> HeroModifier
Parameters
t
the CATransform3D object
-
Set the perspective on the transform. use in combination with the rotate modifier.
Declaration
Swift
public static func perspective(_ perspective: CGFloat) -> HeroModifier
Parameters
perspective
set the camera distance of the transform
-
Scale 3d
Declaration
Swift
public static func scale(x: CGFloat = 1, y: CGFloat = 1, z: CGFloat = 1) -> HeroModifier
Parameters
x
scale factor on x axis, default 1
y
scale factor on y axis, default 1
z
scale factor on z axis, default 1
-
Scale in x & y axis
Declaration
Swift
public static func scale(_ xy: CGFloat) -> HeroModifier
Parameters
xy
scale factor in both x & y axis
-
Translate 3d
Declaration
Swift
public static func translate(x: CGFloat = 0, y: CGFloat = 0, z: CGFloat = 0) -> HeroModifier
Parameters
x
translation distance on x axis in display pixel, default 0
y
translation distance on y axis in display pixel, default 0
z
translation distance on z axis in display pixel, default 0
-
Undocumented
Declaration
Swift
public static func translate(_ point: CGPoint, z: CGFloat = 0) -> HeroModifier
-
Rotate 3d
Declaration
Swift
public static func rotate(x: CGFloat = 0, y: CGFloat = 0, z: CGFloat = 0) -> HeroModifier
Parameters
x
rotation on x axis in radian, default 0
y
rotation on y axis in radian, default 0
z
rotation on z axis in radian, default 0
-
Undocumented
Declaration
Swift
public static func rotate(_ point: CGPoint, z: CGFloat = 0) -> HeroModifier
-
Rotate 2d
Declaration
Swift
public static func rotate(_ z: CGFloat) -> HeroModifier
Parameters
z
rotation in radian
-
Set the opacity for the view to animate from/to.
Declaration
Swift
public static func opacity(_ opacity: CGFloat) -> HeroModifier
Parameters
opacity
opacity for the view to animate from/to
-
Set the backgroundColor for the view to animate from/to.
- backgroundColor: backgroundColor for the view to animate from/to
Declaration
Swift
public static func backgroundColor(_ backgroundColor: UIColor) -> HeroModifier
-
Set the cornerRadius for the view to animate from/to.
Declaration
Swift
public static func cornerRadius(_ cornerRadius: CGFloat) -> HeroModifier
Parameters
cornerRadius
cornerRadius for the view to animate from/to
-
Set the zPosition for the view to animate from/to.
- zPosition: zPosition for the view to animate from/to
Declaration
Swift
public static func zPosition(_ zPosition: CGFloat) -> HeroModifier
-
Set the contentsRect for the view to animate from/to.
- contentsRect: contentsRect for the view to animate from/to
Declaration
Swift
public static func contentsRect(_ contentsRect: CGRect) -> HeroModifier
-
Set the contentsScale for the view to animate from/to.
- contentsScale: contentsScale for the view to animate from/to
Declaration
Swift
public static func contentsScale(_ contentsScale: CGFloat) -> HeroModifier
-
Set the borderWidth for the view to animate from/to.
- borderWidth: borderWidth for the view to animate from/to
Declaration
Swift
public static func borderWidth(_ borderWidth: CGFloat) -> HeroModifier
-
Set the borderColor for the view to animate from/to.
- borderColor: borderColor for the view to animate from/to
Declaration
Swift
public static func borderColor(_ borderColor: UIColor) -> HeroModifier
-
Set the shadowColor for the view to animate from/to.
- shadowColor: shadowColor for the view to animate from/to
Declaration
Swift
public static func shadowColor(_ shadowColor: UIColor) -> HeroModifier
-
Set the shadowOpacity for the view to animate from/to.
- shadowOpacity: shadowOpacity for the view to animate from/to
Declaration
Swift
public static func shadowOpacity(_ shadowOpacity: CGFloat) -> HeroModifier
-
Set the shadowOffset for the view to animate from/to.
- shadowOffset: shadowOffset for the view to animate from/to
Declaration
Swift
public static func shadowOffset(_ shadowOffset: CGSize) -> HeroModifier
-
Set the shadowRadius for the view to animate from/to.
- shadowRadius: shadowRadius for the view to animate from/to
Declaration
Swift
public static func shadowRadius(_ shadowRadius: CGFloat) -> HeroModifier
-
Set the shadowPath for the view to animate from/to.
- shadowPath: shadowPath for the view to animate from/to
Declaration
Swift
public static func shadowPath(_ shadowPath: CGPath) -> HeroModifier
-
Set the masksToBounds for the view to animate from/to.
- masksToBounds: masksToBounds for the view to animate from/to
Declaration
Swift
public static func masksToBounds(_ masksToBounds: Bool) -> HeroModifier
-
Create an overlay on the animating view.
Declaration
Swift
public static func overlay(color: UIColor, opacity: CGFloat) -> HeroModifier
Parameters
color
color of the overlay
opacity
opacity of the overlay
-
Sets the duration of the animation for a given view. If not used, Hero will use determine the duration based on the distance and size changes.
Note: a duration of .infinity means matching the duration of the longest animation. same as .durationMatchLongest
Declaration
Swift
public static func duration(_ duration: TimeInterval) -> HeroModifier
Parameters
duration
duration of the animation
-
Sets the duration of the animation for a given view to match the longest animation of the transition.
Declaration
Swift
public static var durationMatchLongest: HeroModifier
-
Sets the delay of the animation for a given view.
Declaration
Swift
public static func delay(_ delay: TimeInterval) -> HeroModifier
Parameters
delay
delay of the animation
-
Sets the timing function of the animation for a given view. If not used, Hero will use determine the timing function based on whether or not the view is entering or exiting the screen.
Declaration
Swift
public static func timingFunction(_ timingFunction: CAMediaTimingFunction) -> HeroModifier
Parameters
timingFunction
timing function of the animation
-
(iOS 9+) Use spring animation with custom stiffness & damping. The duration will be automatically calculated. Will be ignored if arc, timingFunction, or duration is set.
Declaration
Swift
@available(iOS 9, *) public static func spring(stiffness: CGFloat, damping: CGFloat) -> HeroModifier
Parameters
stiffness
stiffness of the spring
damping
damping of the spring
-
Transition from/to the state of the view with matching heroID Will also force the view to use global coordinate space.
The following layer properties will be animated from the given view.
position bounds.size cornerRadius transform shadowColor shadowOpacity shadowOffset shadowRadius shadowPath
Note that the following properties won’t be taken from the source view.
backgroundColor borderWidth borderColor
Declaration
Swift
public static func source(heroID: String) -> HeroModifier
Parameters
heroID
the source view’s heroId.
-
Works in combination with position modifier to apply a natural curve when moving to the destination.
Declaration
Swift
public static var arc: HeroModifier
-
Works in combination with position modifier to apply a natural curve when moving to the destination.
Declaration
Swift
public static func arc(intensity: CGFloat = 1) -> HeroModifier
Parameters
intensity
a value of 1 represent a downward natural curve ╰. a value of -1 represent a upward curve ╮. default is 1.
-
Cascade applys increasing delay modifiers to subviews
Declaration
Swift
public static var cascade: HeroModifier
-
Cascade applys increasing delay modifiers to subviews
Declaration
Swift
public static func cascade(delta: TimeInterval = 0.02, direction: CascadeDirection = .topToBottom, delayMatchedViews: Bool = false) -> HeroModifier
Parameters
delta
delay in between each animation
direction
cascade direction
delayMatchedViews
whether or not to delay matched subviews until all cascading animation have started
-
Apply modifiers only if the condition return true.
Declaration
Swift
public static func when(_ condition: @escaping (HeroConditionalContext) -> Bool, _ modifiers: [HeroModifier]) -> HeroModifier
-
Undocumented
Declaration
Swift
public static func when(_ condition: @escaping (HeroConditionalContext) -> Bool, _ modifiers: HeroModifier...) -> HeroModifier
-
Undocumented
Declaration
Swift
public static func whenMatched(_ modifiers: HeroModifier...) -> HeroModifier
-
Undocumented
Declaration
Swift
public static func whenPresenting(_ modifiers: HeroModifier...) -> HeroModifier
-
Undocumented
Declaration
Swift
public static func whenDismissing(_ modifiers: HeroModifier...) -> HeroModifier
-
Undocumented
Declaration
Swift
public static func whenAppearing(_ modifiers: HeroModifier...) -> HeroModifier
-
Undocumented
Declaration
Swift
public static func whenDisappearing(_ modifiers: HeroModifier...) -> HeroModifier