タッチしたら画像が出て、消えるというものを作っています。
Tap Gesture RecognizerをActionとつなぎ作りました。
import UIKit class ViewController: UIViewController { @IBAction func tapView(_ sender: UITapGestureRecognizer) { let retu = UIImageView(image: UIImage(named: "烈海王")) retu.alpha = 0 let scaleTransform = CGAffineTransform(scaleX: 0.2, y: 0.2) let rotationTransform = CGAffineTransform(rotationAngle: CGFloat(-Double.pi/2)) _ = scaleTransform.concatenating(rotationTransform) retu.center = sender.location(in: self.view) view.addSubview(retu) UIView.animate(withDuration:2.0, delay:3.0, options:[.curveEaseInOut], animations: { retu.alpha = 1.0 retu.transform = .identity }, completion:{(finished:Bool) in self.view.removeFromSuperview()}) } override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } }
このようにコードを作り、シュミレーターを起動し、画面をタッチすると画像が出てくるのですが、消えるタイミングで画面が真っ暗になってしまします。
アドバイスや解決方法がある方助言をお願いします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/11/28 06:09
2018/11/28 06:13