I want to be able to swipe transition right gestures between the two states of a UIView with a swipe left. Basically I want to start increasing the height of the scene because the user starts swiping to the left and becomes "shrinking" when it swipe. I can easily animate with CAN Animation between the two states, but what I want is ideal that it is the signal to control the transition rather than giving it "duration". So essentially mapping the extension / shrinkage of the boundary height of the signal ... I am doing a terrible thing to explain to myself, but Apple is all this time.
Here's how it appears in your custom UIView moment:
class CustomUIView: UIView {@IBOutlet bridesmaid swipeView: UIView! Var must have Except Expand Animation: Boole = True; Var needs extract shank animation: Bool = true; Required init (coder aDecoder in: NSCoder) {super.init (Coder: aDecoder) NSBundle.mainBundle () loadNibNamed ( "CustomUIView", the owner himself, option: zero). SwipeView.backgroundColor = UIColor.grayColor () self.addSubview (Self.swipeView) func performAnimation (Transansform: CATransform3D, toTransform: CATransform3D, duration: CFTimeInterval) {var animation: CABasicAnimation = CABasicAnimation (keyPath: "transform") animation. = self var transformView = conversion animation .fromValue = NSValue (CATransform3D: fromTransform) animation.toValue = NSValue (CATransform3D: toTransform) animation.duration = term self.swipeView.layer.addAnimation (animation, forKey: zero) self.swipeView.layer .transform = toTransform} expandView () {function if shouldExecuteExpandAnimation {performAnimation (CATransform3DIdentity, toTransform: CATransform3DMakeScale (1, 4, 1), duration: 0.1) executeShrinkAnimation = true; } ExxuteExpandAnimation = false; } Func shrinkView () {ifxexuteShrinkAnimation {executeAnimation (CATransform3DMakeScale (1, 4, 1), toTransform: CATransform3DMakeScale (1, 1, 1), duration: 0.1) shouldxecuteExpandAnimation = true} Chahiaakseksrenkanimeshn = false; } Func manageViewWithGesture {switch gestureRecognizer} {switch gestureResourceDescriptions {Case} UISwipeGestureRecognizerDirection.Right: expandView () Case UISwipeGestureRecognizerDirection.Left: shrinkView () Default: break}}}
No comments:
Post a Comment