5
8

More than 3 years have passed since last update.

UIScrollViewのスクロール量を利用した昇降ViewController

Last updated at Posted at 2019-09-08

今年もiOSDCでモチベーションがすこし上がったので、便利そうなUIサンプルを作ってみました。
写真を使った検索などでよく見られるUIですね。

プレビュー

sample.gif

ポイント

  • addChildでchildViewControllerとして表示しています。
  • 上下バウンス効果からもわかるようにスクロールの力だけで昇降させています。そのため一度上に上げてからスクロールさせるという2ステップジェスチャーが不要です。
  • UIScrollViewDelegateにさえ対応してさえいれば適応できるのでTableViewやCollectionView, WebViewなどにも応用できます。

:octocat: ShingoFukuyama/LiftableScrollViewController.swift

UIScrollViewのcontentInsetやCGAffineTransformを組み合わせた全100行くらいのシンプルなコードなので、詳細はgistを覗いてみてください。

5
8
0

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
5
8