Created
November 6, 2018 18:38
-
-
Save vialyx/e387c8e8c8726cd8a492d25035602c94 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MARK: - Actions | |
@IBAction func buttonDidTap(_ sender: Any) { | |
// Check text in field. Animation is starting only if text is empty | |
if field.text?.isEmpty ?? true { | |
UIView.animate(withDuration: 0.3, | |
delay: 0.0, | |
// Look options list here https://developer.apple.com/documentation/uikit/uiviewanimationoptions | |
options: [.autoreverse], | |
animations: { | |
// Create CGAffineTransform with 5 degree (CG works with radians) and convert in to radians | |
self.field.transform = CGAffineTransform(rotationAngle: CGFloat(5).degreesToRadians) | |
// Add scale factor to the created transform | |
.scaledBy(x: 1.2, y: 1.2) | |
}) { (finish) in | |
// Clear transform .identity is a empty transform | |
self.field.transform = .identity | |
print("\(String(describing: self.field)) animation finish: \(finish)") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment