CopyPastor

Detecting plagiarism made easy.

Score: 0.8207451701164246; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2020-01-10
by jawadAli

Original Post

Original - Posted on 2019-11-05
by Brody Robertson



            
Present in both answers; Present only in the new answer; Present only in the old answer;

This approach allows us to directly use the UIView.AnimationOptions.repeat

public extension UIView { func animateRotation(duration: TimeInterval, repeat: Bool, completion: ((Bool) -> ())?) { var options = UIView.KeyframeAnimationOptions(rawValue: UIView.AnimationOptions.curveLinear.rawValue) if `repeat` { options.insert(.repeat) } UIView.animateKeyframes(withDuration: duration, delay: 0, options: options, animations: { UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.25, animations: { self.transform = CGAffineTransform(rotationAngle: CGFloat.pi/2) }) UIView.addKeyframe(withRelativeStartTime: 0.25, relativeDuration: 0.25, animations: { self.transform = CGAffineTransform(rotationAngle: CGFloat.pi) }) UIView.addKeyframe(withRelativeStartTime: 0.5, relativeDuration: 0.25, animations: { self.transform = CGAffineTransform(rotationAngle: 3*CGFloat.pi/2) }) UIView.addKeyframe(withRelativeStartTime: 0.75, relativeDuration: 0.25, animations: { self.transform = CGAffineTransform(rotationAngle: 2*CGFloat.pi) }) }, completion: completion) } }
**Swift 5 UIView Extension using Keyframe Animations**
This approach allows us to directly use the UIView.AnimationOptions.repeat
public extension UIView { func animateRotation(duration: TimeInterval, repeat: Bool, completion: ((Bool) -> ())?) { var options = UIView.KeyframeAnimationOptions(rawValue: UIView.AnimationOptions.curveLinear.rawValue) if `repeat` { options.insert(.repeat) } UIView.animateKeyframes(withDuration: duration, delay: 0, options: options, animations: { UIView.addKeyframe(withRelativeStartTime: 0, relativeDuration: 0.25, animations: { self.transform = CGAffineTransform(rotationAngle: CGFloat.pi/2) }) UIView.addKeyframe(withRelativeStartTime: 0.25, relativeDuration: 0.25, animations: { self.transform = CGAffineTransform(rotationAngle: CGFloat.pi) }) UIView.addKeyframe(withRelativeStartTime: 0.5, relativeDuration: 0.25, animations: { self.transform = CGAffineTransform(rotationAngle: 3*CGFloat.pi/2) }) UIView.addKeyframe(withRelativeStartTime: 0.75, relativeDuration: 0.25, animations: { self.transform = CGAffineTransform(rotationAngle: 2*CGFloat.pi) }) }, completion: completion) } }


        
Present in both answers; Present only in the new answer; Present only in the old answer;