Created
September 2, 2019 13:52
-
-
Save DaisukeNagata/4bafcbd5c11461c76140e8d9df3c68c5 to your computer and use it in GitHub Desktop.
buttonAnimationBig
This file contains 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
import UIKit | |
class ViewController: UIViewController { | |
let caButton = UIButton() | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
caButton.backgroundColor = .yellow | |
caButton.frame = CGRect(x: 320, y: 20, width: 0, height: 0) | |
view.addSubview(caButton) | |
self.caButton.alpha = 0 | |
self.navigationController?.navigationBar.addSubview(caButton) | |
buttonAnimationBig() | |
} | |
func buttonAnimationBig() { | |
UIView.animate(withDuration: TimeInterval(0.4), | |
animations: {}, completion: { _ in | |
UIView.animate(withDuration: 0.2, | |
animations: { | |
self.caButton.alpha = 1 | |
self.caButton.frame.origin.x -= 50 | |
self.caButton.frame.origin.y -= 20 | |
self.caButton.frame.size.width += 100 | |
self.caButton.frame.size.height += 40 | |
}) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment