PlayGround Article ブログ, デザイン, アプリ 【iOS】Twitterの投稿ボタンのアニメーションをトレースしてみる mcz9mm 2019年1月27日 Created with Sketch. 1 Created with Sketch. 242 hiroyoshi 人類の進歩、進化を加速させていく こんにちは。 今回はTwitterでの投稿ボタンのアニメーションをトレースしたいと思います。 ## トレースするもの  ## 実装 ``` button.addTarget(self, action: #selector(upInside(_:)), for: .touchUpInside) button.addTarget(self, action: #selector(onDown(_:)), for: .touchDown) button.addTarget(self, action: #selector(dragExit(_:)), for: .touchDragExit) ``` ``` @objc func upInside(_ sender: UIButton) { UIView.animate(withDuration: 0.15, delay: 0, options: [.curveEaseIn], animations: { self.button.transform = CGAffineTransform(scaleX: 0.7, y: 0.7) self.button.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) }) { _ in // Do Something } } @objc func onDown(_ sender: UIButton){ UIView.animate(withDuration: 0.15, delay: 0, options: [.curveEaseIn], animations: { self.button.transform = CGAffineTransform(scaleX: 0.7, y: 0.7) }) { _ in } } @objc func dragExit(_ sender: UIButton){ UIView.animate(withDuration: 0.15, delay: 0, options: [.curveEaseIn], animations: { self.button.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) }) { _ in } } ``` ## できたもの 