有了這個App就能成為天氣之子了(吧

這裡應該有個副標題

(1) App畫面 gif

App操作gif

(2) GitHub連結

(3) 特製App截圖

轉跳的sheet

(4) 文字說明

先放個漂亮的電影海報😎,

天氣之子電影海報

這是一部關於一位能夠改變天氣的少女的故事。

這次不知道哪裡來得靈感,可能是因為基隆這幾一陣子下太多雨吧🤪。

於是我就將這次作品設計成一款可以自由控制特定台灣地區的天氣的App,可以以設定城市、設定時間點還可以指定天氣狀況,484很棒呢😈。

這次的作品一樣將很多彩蛋藏在各種神奇的地方,快去尋找,並成為天氣之子吧!

  • 使用到亂數
  • 顯示 Alert
很爛的笑話

(5) 重點程式碼講解(加分內容)

  • 使用 onChange modifier
Toggle("顯示隱藏城市", isOn: $secretCity).onChange(of: secretCity, perform: { value inif (value){cities[10].name = "苗栗國😺"} else{cities[10].name = "😺苗栗國"}})
  • 顯示 ActionSheet
Button(action: {showActionSheet = true}, label: {HStack{Image(cities[cityIdx].pPath).resizable().scaledToFit().frame(width: 150)Image(systemName: "plus")Image(systemName: weatherList[weatherIdx].pPath).resizable().scaledToFit().frame(width: 150)}}).actionSheet(isPresented: $showActionSheet) {ActionSheet(title: Text("在此聲明"), message: Text("本產品成功率<\(Int.random(in: 5...50))%"), buttons: [.default(Text("我當然知道囉"))])}

截圖:

  • 顯示 ContextMenu
Button(action: {showResult = true}, label: {Text("  設定天氣!").font(.headline).padding().background(btnColor).cornerRadius(20.0).foregroundColor(.white)}).sheet(isPresented: $showResult, content: {ResultView(cityIdx: $pickedCity, weatherIdx: $pickedWeather, wPoint: $weatherPoint)}).contextMenu{Text("按鈕可以換顏色!")}

截圖:

--

--