アプリを作成していて、ナビゲーション ビューの 1 つで、App Store アプリと非常によく似たデザインを使用しています。詳細 | を参照してください。レビュー | 関連セクション。同様の行に従って、Apple がアプリで行った「同じ」方法でセグメント化されたコントロールを実装したいと考えています。(これは、Apple がデフォルトの iOS 7 音楽アプリの [アーティスト] -> [アルバム] ナビゲーション ビューで行っていることと似ていますが、テーブル ヘッダーについては (おそらく))。
- 上にスクロールすると、セグメント化されたコントロール コンテナーがナビゲーション バーに触れると、そこに固定されます。
- また、ユーザーは、関連付けられたアルファにより、これがある種のオーバーレイであることを認識できます。
- 下にスクロールすると、必要な位置に移動します。
私がしたこと —</p>
セグメント化されたコントロールを含むコンテナー ビューを作成しました。scrollView がスクロールしたら、コンテナ ビューの位置を変更して、スティッキー効果を実現します。これは単なる擬似コードですが、私のコードは実際に機能します。
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (scrollView == self.labTestScrollView)
{
/*
As soon as the user scrolls up, y changes, therefore, we need to stick the options container view
such that it doesn't go past the UINavigationBar
Need to check if the origin of the options container view in the coordinate system of the main
superview is just gone past the UINavigationBar in this controller's view.
- get the bounds rect for the options container view
- convert these bounds and position them in the coordinates of this controller's view
- check if origin.x for container view is less than that of view.origin.y
- if less than stick it by converting the headerFrame to the coordinate system of the options
container view; and raise the stuck flag
- if greater, check if the stuck flag is raised; check for another object in space before the container view and adjust accordingly.
*/
}
}
2 つの問題があります。
- オーバーレイ効果なし。効果がもう少し目立つようにアルファを設定できますが、それは自然に見えません。
- 2 番目の懸念は、最初の懸念に由来します。これは非常に具体的な解決策のようです。もっと自然な何かを楽しみにしています。テーブルビューなどを使用してデフォルトで機能する可能性のあるもの。