

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? |
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 |
/// 多角形のシェープ. | |
struct Polygon : Shape { | |
/// 多角形の頂点の数. デフォルト値は`3` | |
var numberOfVertex: Int | |
/// 角の半径. デフォルト値は`3`. | |
var cornerRadius: CGFloat | |
/// 直線をトップに配置するかどうかのBool値. デフォルト値は`false`. |
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() |
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) |
// 🌱 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) { |
昔に書いていた未完結の記事ですが、それでも宜しければどうぞです🙏
あなたは今年こそ SwiftUI を学ぶ必要があると感じている。
それは今年の WWDC20 で発表された Widget と呼ばれる機能が SwiftUI でしか作成できないことを聞いたからかもしれないし、SwiftUI 100% でマルチプラットフォームのアプリを作成できるようになったからかもしれないし、あるいはいつまでも UIKit に依存しているのはリスクだと感じ取ったのかもしれない。
学習の上で一番難しい部分は、SwiftUI で考えるということだ。従来の命令的でステートフルなプログラミングから離れて、宣言的でステートレスに考えるように脳を強制しなくてはならない。すでに日本でも SwiftUI の書籍はいくつか発売されているが、その多くは使い方に関することが中心で、SwiftUI が**どのように動くのか(How it works)**についての解説は不足しているものが多いように感じる。