uiviewanimation
UIView.animate – Swift 3 – completion
You add it like this: UIView.animate(withDuration: 0.25, delay: 0.0, options: [], animations: { self.drawerView?.frame = CGRect(x: 0, y: 0, width: (self.drawerView?.frame.size.width)!, height: (self.drawerView?.frame.size.height)!) self.contentView?.frame = CGRect(x: 200, y: 0, width: (self.contentView?.frame.size.width)!, height: (self.contentView?.frame.size.height)!) }, completion: { (finished: Bool) in self.isOpen = true })
UIView animations with autoreverse
You have three options. When you use the -[UIView animateWithDuration:…] methods, the changes you make in the animations block are applied immediately to the views in question. However, there is also an implicit CAAnimation applied to the view that animates from the old value to the new value. When a CAAnimation is active on a … Read more
How to make UIView animation sequence repeat and autoreverse
To animation from point 1 to 2 to 3 to 2 to 1 and repeat, you can do use animateKeyframesWithDuration in iOS 7 and later: someView.frame = frame1; [UIView animateKeyframesWithDuration:2.0 delay:0.0 options:UIViewKeyframeAnimationOptionAutoreverse | UIViewKeyframeAnimationOptionRepeat animations:^{ [UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.5 animations:^{ someView.frame = frame2; }]; [UIView addKeyframeWithRelativeStartTime:0.5 relativeDuration:0.5 animations:^{ someView.frame = frame3; }]; } completion:nil]; If using … Read more
UIView animation based on UIPanGestureRecognizer velocity
The docs say The velocity of the pan gesture, which is expressed in points per second. The velocity is broken into horizontal and vertical components. So I’d say, given you want to move your view xPoints (measured in pt) to let it go off-screen, you could calculate the duration for that movement like so: CGFloat … Read more
UIView animation options using Swift
Swift 3 Pretty much the same as before: UIView.animate(withDuration: 0.2, delay: 0.2, options: UIViewAnimationOptions.repeat, animations: {}, completion: nil) except that you can leave out the full type: UIView.animate(withDuration: 0.2, delay: 0.2, options: .repeat, animations: {}, completion: nil) and you can still combine options: UIView.animate(withDuration: 0.2, delay: 0.2, options: [.repeat, .curveEaseInOut], animations: {}, completion: nil) Swift … Read more
UIView.animateWithDuration swift loop animation
No need to do the completion block approach, just use the animation options argument: updated for Swift 3.0 UIView.animate(withDuration: 2.0, delay: 0, options: [.repeat, .autoreverse], animations: { coloredSquare.frame = CGRect(x: 120, y: 220, width: 100, height: 100) }, completion: nil) If for any reason you want to stop the animation later, just use: coloredSquare.layer.removeAllAnimations()