-
Notifications
You must be signed in to change notification settings - Fork 127
CardAnimation Technical Point
like: (0.5, 0.5) ->(0.5, 1)
Frame:
There are many ways to do this:
subView.frame = frame
subView.layer.anchorPoint = CGPointMake(0.5, 1)
subView.frame = frame
AutoLayout:
Discussion on stackoverflow, but I find a simple way:
let subViewHeight =
let oldConstraintConstant = centerYConstraint.constant
subView.layer.anchorPoint = CGPointMake(0.5, 1)
//Like what you do with frame, you need to compensate for additional translation.
centerYConstraint.constant = subView.bounds.size.height/2 + oldConstraintConstant
From iOS 8, transform and autolayout play nice. There is a blog for this: Constraints & Transformations
Transform doesn't affect autolayout, only constraints can affect autolayout.
Transform affects view's frame, but do nothing to view's center and bounds.
Use a subview, and change the container view's background color to what color you want.
When the container view is vertical to screen, make the subview hidden, and after the container view back, make subview visible.
let flipTransform = CATransform3DRotate(CATransform3DIdentity, CGFloat(-M_PI), 1, 0, 0)
UIView.animateWithDuration(0.3, {
view.layer.transform = flipTransform
})
The animation will not execute and the view just change if you execute above code in an action method, like clip a button. UIView keyFrame animation works fine.