ボタンを押したらストーリーボード上に配置したビューの角が丸くなるコードを書いているのですが、ボタンを押しても変化がありません。なぜでしょうか。
Swift
1import UIKit 2 3class ViewController: UIViewController { 4let targetView = UIView() 5 override func viewDidLoad() { 6 super.viewDidLoad() 7 // Do any additional setup after loading the view. 8 } 9 10 @IBAction func tapStartBotoon(_ sender: Any) { 11 let animation = CABasicAnimation(keyPath: "cornerRadius") 12 animation.timingFunction = CAMediaTimingFunction(name: CAMediaTimingFunctionName.default) 13 14 animation.fromValue = 0 15 animation.toValue = 20 16 animation.duration = 1 17 18 targetView.layer.add(animation, forKey: "cornerRadius") 19 targetView.layer.cornerRadius = 20 20 } 21 22} 23
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/02/26 22:37
2020/02/27 01:06
2020/02/27 01:09
2020/02/27 01:21