#2 來去空桑Play-食物語電子書

食物語電子書Storyboard結構圖

一個持續玩了快3年的遊戲,用IOS APP做一個電子書紀念一下囉~

使用Storyboard及UIKit幾個基本的元件完成APP — 食物語電子書。

使用到的元件:

Tab Bar Controller、Navigation Controller、Table View Controller、View Controller、Container View、Scroll View、Image View、Text View、Label、Segue

1.製作食物語遊戲”介紹”畫面:

(1) 點選成立專案時就己產生的View Controller

(2) 點擊Editor Window右下方的Embed in鈕,在選單中選擇Tab Bar Controller

(3) 在Inspector修改View Controller上Bar Item中的Title=介紹、Image=book.fill

(4) 將Container View及Image View新增到View Controller(注意:Container View要在Image View的上方,以免被Image View遮到內容),2個元件大小拉成View Controller大小一致,並刪除Container View預設產生的View Controller,Image View=Background-1.png

(5) 新增空白View Controller至Editor Window,於新增的View Controller中增加各1個Image View及Text View,調整成想要的大小後,設定Image=介紹header.png、TextView貼上介紹文內容

(6) 從Container View拉線(Segue)至新增的View Controller,在選單中選擇Embed,之後將View Controller、Text View的Background=Clear Color這樣才能看到背景圖

2.製作”食魂”畫面:

(1) 複製”介紹”畫面Image View=Background-1.png,改成Image View=Background-2.png,點擊修改後的View Controller,點Editor Window右下的Embed in鈕,選擇Navigation Controller(提示:如果誤刪Navigation Controller至連線目的View Controller的Segue,可由Navigation Controller再拉一次,選單中選root view controller即可)

(2) 從Tab Bar Controller拉線(Segue)至上個步驟新增的Navigation Controller,在選單選擇view controllers,接著修改Navigation Controller下方的Bar Item中的Title=食魂、Image=person

(3) 新增Table View Controller,從Image View=Background-2.png的Container View拉線(Segue)到Table View Controller,選單選擇Embed,修改Inspector Table View的content=Static Cells,刪除Structure的Table View下方2個Cell,待第一個Cell設定好之後用複製的比較快

(4) Table View改成Static Cell後,Table View會產生預設的Header及Footer要將Inspector中Section下Header及Footer的Estimate=0,才不會畫面上下都出現灰色條塊遮住畫面

(5) 新增View至Structure Window中Table View Controller的Table View與Table View Section中間當成header,並在header中新增Scroll View,讓圖片可以左右移動檢視(細節:參考”設定 content size,實現水平捲動,上下捲動和分頁的 scroll view”),新增Button覆蓋在Image View之上,再拉線(Segue)到Detail View Controller即可實現點選Scroll View圖片轉到食魂簡介紹畫面

(6) Cell中新增各1個Image View及Label,調整好要的樣式後複製需求的數量,並設定Image View及Label

(7) 新View Controller製作點選Cell出現的內容畫面,在View Controller上新增Image View、Label、Text View各一個調整成想要的樣式後,複製跟Cell一樣的數量

(8) 從Cell依序拉線(Segue)到對應的View Controller

(9) 新增一個空白的View到Table View Controller上方的Item Bar,在Table View Controller上方會出現空白的View,將View的Background=Clear Color,然後將Table View Cell拉線到這個View,選單點選selectedBackgroundView,則點Cell就不會有顏色出現(參考:設定表格 cell 點選時的背景顏色)

成品GIF:

--

--

Tai
彼得潘的 Swift iOS / Flutter App 開發教室

跌跌撞撞走了編碼人生的前半段,一切又得重來~但勇敢站起來,決定從 IOS APP 作為下一個人生段的起點,好好的再走他一段編碼人生!