Skip to content

Commit

Permalink
animate background color
Browse files Browse the repository at this point in the history
  • Loading branch information
lkzhao committed Feb 17, 2017
1 parent 2f34c62 commit d21c623
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/HeroCoreAnimationViewContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ internal class HeroCoreAnimationViewContext: HeroAnimatorViewContext {
state.cornerRadius != nil ||
state.opacity != nil ||
state.overlay != nil ||
state.backgroundColor != nil ||
state.borderColor != nil ||
state.borderWidth != nil ||
state.shadowOpacity != nil ||
Expand Down Expand Up @@ -204,6 +205,9 @@ internal class HeroCoreAnimationViewContext: HeroAnimatorViewContext {
if let cornerRadius = targetState.cornerRadius {
rtn["cornerRadius"] = NSNumber(value: cornerRadius.native)
}
if let backgroundColor = targetState.backgroundColor {
rtn["backgroundColor"] = backgroundColor
}
if let zPosition = targetState.zPosition {
rtn["zPosition"] = NSNumber(value: zPosition.native)
}
Expand Down
11 changes: 11 additions & 0 deletions Sources/HeroModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,17 @@ extension HeroModifier {
}
}

/**
Set the backgroundColor for the view to animate from/to.
- Parameters:
- backgroundColor: backgroundColor for the view to animate from/to
*/
public static func backgroundColor(_ backgroundColor: UIColor) -> HeroModifier {
return HeroModifier { targetState in
targetState.backgroundColor = backgroundColor.cgColor
}
}

/**
Set the cornerRadius for the view to animate from/to.
- Parameters:
Expand Down
1 change: 1 addition & 0 deletions Sources/HeroTargetState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public struct HeroTargetState {
internal var transform: CATransform3D?
internal var opacity: Float?
internal var cornerRadius: CGFloat?
internal var backgroundColor: CGColor?
internal var zPosition: CGFloat?

internal var borderWidth: CGFloat?
Expand Down

0 comments on commit d21c623

Please sign in to comment.