上のビューをTopView, 下のビューとBottomView, スプリッターとなるビューとVSplitterとします。
・TopViewのBottom、BotttomViewのTopをVSplitterにくっつけておきます。
(それ以外の辺は適当にSuperviewにくっつけておきます)
・VSpliterは高さを適当に設定してTopをSuperviewからのオフセットにしておきます。
⇨このTop位置のConstraintをソースに接続しておきます(vSplitterTopConstraint)
・VSpliterにPanGestureRecognizerを追加してSent Actionsをソースに接続しておきます(onPanGestureAction)
あとは以下のような感じでPan Gestureでの移動量をConstraintに足していくとドラッグできます。
毎回setTranslationで移動量を0に戻してやるのがポイントです。
Swift
1class ViewController: UIViewController {
2 @IBOutlet weak var vSplitterTopConstraint: NSLayoutConstraint!
3
4 @IBAction func onPanGestureAction(_ gr: UIPanGestureRecognizer)
5 {
6 let move = gr.translation(in: self.view)
7
8 vSplitterTopConstraint.constant += move.y
9 gr.setTranslation(CGPoint.zero, in: self.view)
10 }
11}
このままだとサイズがマイナスになったらクラッシュするのでその辺は最大最小値を決めるなりしてください。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/11 00:09