WWDC 2006 2007 2008 2009 2010 2011 2012 2013 2014
昔に書いていた未完結の記事ですが、それでも宜しければどうぞです🙏
あなたは今年こそ SwiftUI を学ぶ必要があると感じている。
それは今年の WWDC20 で発表された Widget と呼ばれる機能が SwiftUI でしか作成できないことを聞いたからかもしれないし、SwiftUI 100% でマルチプラットフォームのアプリを作成できるようになったからかもしれないし、あるいはいつまでも UIKit に依存しているのはリスクだと感じ取ったのかもしれない。
学習の上で一番難しい部分は、SwiftUI で考えるということだ。従来の命令的でステートフルなプログラミングから離れて、宣言的でステートレスに考えるように脳を強制しなくてはならない。すでに日本でも SwiftUI の書籍はいくつか発売されているが、その多くは使い方に関することが中心で、SwiftUI が**どのように動くのか(How it works)**についての解説は不足しているものが多いように感じる。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 🌱 Inspired by and special thanks! | |
| // https://gist.github.com/Koshimizu-Takehito/737381f5e55678e691205fe11fe16e93 | |
| import SwiftUI | |
| struct ContentView: View { | |
| var body: some View { | |
| HStack(spacing: 12) { | |
| ForEach(["applelogo", "swift"], id: \.self) { name in | |
| VStack(spacing: 12) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct ContentView: View { | |
| @State private var tick: Int = 0 | |
| @State private var opacity: Double = 0 | |
| @State private var inverse = true | |
| var body: some View { | |
| TimelineView(.animation) { timeline in | |
| content(timeline.date) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct HugginFaceProgressCircle: View { | |
| @State private var rotationDegrees: [Double] = [0, 0, 0] | |
| @State private var startTrim: [CGFloat] = [0, 0, 0] | |
| @State private var trimTo: CGFloat = 120.0 / 360.0 | |
| @State private var shouldRotate = true | |
| @State private var opacity = 1.0 | |
| let timer = Timer.publish(every: 0.1, on: .main, in: .common).autoconnect() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// 多角形のシェープ. | |
| struct Polygon : Shape { | |
| /// 多角形の頂点の数. デフォルト値は`3` | |
| var numberOfVertex: Int | |
| /// 角の半径. デフォルト値は`3`. | |
| var cornerRadius: CGFloat | |
| /// 直線をトップに配置するかどうかのBool値. デフォルト値は`false`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| struct EnumPicker<Enum>: View where Enum: CaseIterable & Hashable, Enum.AllCases: RandomAccessCollection { | |
| typealias Element = Enum.AllCases.Element | |
| private var enumType: Enum.Type | |
| @Binding private var selection: Element | |
| init(_ enumType: Enum.Type, selection: Binding<Element>) { | |
| self.enumType = enumType |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SwiftUI | |
| // https://x.com/jrsaruo_tech/status/1893585977760743750 | |
| @available(iOS 18, *) | |
| struct HorizontalInlinePicker<SelectionValue, Content>: View where SelectionValue: Hashable, Content: View { | |
| @Binding var selection: SelectionValue | |
| @State private var centerValue: SelectionValue? |
OlderNewer
