研究 navigation controller 手勢觸發 bar 隱藏的功能: navigation controller 元件的 Hide Bars 欄位

MikeWang
MikeWang
Jul 29, 2017 · 3 min read

現在我才知道……
原來標題可以打這麼多字XDDDD,
沒錯,今天的目的就是研究bar 隱藏的功能。

分別有四種效果:
a.滑動觸發隱藏,
b.點擊觸發隱藏,
c.開啟鍵盤觸發隱藏,
d.切換到垂直緊密觸發隱藏Navigation Bar

按照慣例,先上圖

Bar 尚未隱藏前:

完成圖:

說明:

從完成圖可以看到一開始畫面的上方有一個Bar( ̶b̶e̶e̶r̶B̶a̶r̶),
第一個隱藏Bar的方法,是滑動手勢來觸發隱藏Bar,
緊接者第二個方法是點擊來觸發隱藏,
第三個是切換螢幕方向來觸發隱藏,
最後是開啟輸入鍵盤來觸發隱藏。
由於要收合虛擬鍵盤,要透過寫程式的方式,在本範例中就先不示範了。

小技巧筆記:

  1. Apple開發者網站,可以快速搜尋需要的資料 (e.g. UIKit)
  2. Navigation Controller在程式碼內,也有對應的property可以設定
  3. 原來medium的文章標題可以打很多很多字

GitHub:

參考資料:

1. Apple開發者網站 The Adaptive Model

2. Apple開發者網站UINavationController

3. Leo Shih大大的文章

4. IOS大小類別

彼得潘的 Swift iOS App 開發教室

學習 Swift iOS App 開發的學生作品集

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade