LoginSignup
3

More than 5 years have passed since last update.

フワっとしたPopupを出してみる。

Posted at

見た目

movie.gif

(gifだとわかりづらい…orz)

処理抜粋

PopupViewController.swift

    override func viewDidLoad() {
        super.viewDidLoad()

        self.baseViewWidthConstraint.constant = 0
        self.baseViewHeightConstraint.constant = 0
        self.view.layoutIfNeeded()
    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        self.baseViewWidthConstraint.constant = 250
        self.baseViewHeightConstraint.constant = 250

        UIView.animate(withDuration: 1.2, delay: 0.3, usingSpringWithDamping: 0.6, initialSpringVelocity: 10, options: .curveEaseOut, animations: { () -> Void in

            self.baseView.alpha = 1.0
            self.view.layoutIfNeeded()

        }, completion: nil)
    }

・AutoLayoutでPopupのサイズをいじってアニメーションを実現しています。
・高さも変えるため、baseViewのHeightの制約のPriorityを下げています。

コードはこちらです。

もう少し滑らかでくっきりとバウンドがわかるような処理にしたい(´・ω・`)

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3