Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Help us understand the problem. What is going on with this article?

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

More than 3 years have passed since last update.

見た目

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を下げています。

コードはこちらです。

https://github.com/tony1224/PopupAnimationSample

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

kamui_project
Mobile App Engineer / 元日課メーター管理人
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away