Is there a public API for card view UI that can be seen across iOS 10?

后端 未结 4 927
盖世英雄少女心
盖世英雄少女心 2020-12-07 09:06

The Music app in iOS 10 adopts a new card-like appearance: Now Playing screen slides up, while the view below in the hierarchy zooms out, protruding slightly at the top of t

4条回答
  •  日久生厌
    2020-12-07 09:36

    Ok, I'll try to give you a compact solution with a minimum of code.

    Fast solution. You need to present a controller modally with modalPresentationStyle-property set to .overCurrentContext. You can set the value before preset(controller:...)-method get called or in prepare(for:...)-one if it's a segue transition. For sliding up use modalTransitionStyle set to .coverVertical.

    To "zoom out" source view just update its bounds in viewWill(Diss)appear-methods. In most of cases this will work.

    Don't forget to set your modal controller background view transparent so the underlying view still be visible.

    Sliding up/down smoothly. You need to setup a transition between the controllers in a proper way. If you look closer to Apple music app, you'll see a way to hide top controller with slide down gesture. You can customise your view (dis)appearance too. Take a look at this article. It uses UIKit-methods only. Unfortunately this way requires lots of code, but you can use 3rd party libraries to setup transitions. Like this one.

提交回复
热议问题