如何使用 SwiftUI 使 DatePicker 中日期的字体变小?
struct TestView: View {
@State private var eventDate = Date()
var body: some View {
ZStack {
Color(.purple).edgesIgnoringSafeArea(.all)
VStack {
Section {
DatePicker("Event Date", selection: $eventDate, in: ...Date())
.labelsHidden()
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 这段代码显示了我试图实现的一般行为,但如何才能使其连续,使图像没有明显的结尾,没有空白间隙和平滑过渡?并且 - 有没有更好的方法来做到这一点???
谢谢!
import SwiftUI
struct ContentView: View {
@State private var xVal: CGFloat = 0.0
@State private var timer = Timer.publish(every: 0.05, on: .main, in: .common).autoconnect()
var body: some View {
ZStack {
Image("game_background_2") //image attached
.aspectRatio(contentMode: .fit)
.offset(x: xVal, y: 0)
.transition(.slide)
.padding()
.onReceive(timer) {_ in
xVal += 2
if xVal == 800 { xVal = 0 }
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Run Code Online (Sandbox Code Playgroud)
swiftui ×2