1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Swift】FloatingPanelを使った、取っ手のないハーフモーダル実装と背景タップで閉じる処理

Last updated at Posted at 2021-03-16

どういうことか

こういうのを作る。

Simulator Screen Shot - iPhone 11 Pro Max - 2021-03-16 at 16.42.25.png

よくあるドラムロール(PickerView)に見えるが、xibでUIを作ってハーフモーダルに載せている(TextFieldを使った実装だとバグることがあってよくないみたい)。

取っ手を非表示にする

取っ手(ハンドル?棒?伝わりやすい名前はなんだろう)を非表示にする。

let fpc = FloatingPanelController()
    
fpc.surfaceView.grabberHandle.isHidden = true

背景をタップで閉じる

モーダルの外をタップすると閉じる。

let fpc = FloatingPanelController()
    
fpc.backdropView.dismissalTapGestureRecognizer.isEnabled = true

おわり(´・ω・`)

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?