SwiftUI

SwiftUI で画面下部にボタンを置く

NG 画面下部にボタンを置く場合、 bottom の Safe Area に被らないように置かないといけない。 何も考えずに置くと、下記のように Safe Area まで拡張されずに残念な感じになる。 VStack(spacing: .zero) { List(0..<100) { index in Text("\(index)") } But…

SwiftUI のボーダーボタン と clipped

四角ボタン 四角のボタンにボーダーをつける場合は .border modifier を指定すれば作れる。 Button("四角のボーダーボタン", action: {}) .frame(height: height) .padding() .background(Color.orange) .border(Color.red, width: borderWidth) 四角のボー…

SwiftUI の ScrollView を CustomShape で clip すると内部の View まで clip される

下記のように ScrollView に対して clippedShae(_:) で CustomShape を適用して clip すると、 ScrollView 内の View まで clip されてしまって View が途中で切れてしまう。 Rectangle 等の組み込みの Shape や、List に対してであれば問題は生じない。 Sta…

SwiftUI で透明な View に Gesture を設定する

下記のように、Color.clear のような透明のビューにジェスチャーを追加したかったけど反応しなかった。 import SwiftUI struct ExampleView: View { @State var text: String = "ケバブ" var body: some View { ZStack { Color.clear .onTapGesture { text =…