是否有可能在 SwiftUI 中停用按钮?找不到任何东西?
我想使用 Alamofire 进行下载,然后在成功下载后激活按钮。
我无法NavigationLink在 SwiftUI 中获得。按钮是可见的,但不幸的是这是灰色的,无法点击。
这是代码:
import SwiftUI
import Combine
struct ContentView: View {
var body: some View {
NavigationView{
NavigationLink(destination: Text("Detail for Test")) {
Text("Test")
}.navigationBarTitle("Select a user")
}
}
}
Run Code Online (Sandbox Code Playgroud)
有谁知道问题所在?
我想使用变量在视图中调用不同的操作表。这并不意味着工作。
.actionSheet(isPresented: self.$neuinitialisierung) {
ActionSheet(
title: Text("Testtitel 1"),
message: Text("Testmessage 1"),
buttons: [
.default(Text("Button 1"),
action: {
print("KLICK")
}),
.default(Text("Button 2"),
action: {
self.clouddienst_waehlen = true;
})
])
}
.actionSheet(isPresented: self.$clouddienst_waehlen) {
ActionSheet(
title: Text("Testtitel 2"),
message: Text("Testmessage 2"),
buttons: [
.default(Text("Button 1"),
action: {
print("KLICK")
}),
.default(Text("Button 2"),
action: {
self.clouddienst_waehlen = true;
})
])
}
Run Code Online (Sandbox Code Playgroud)
如果我只用一张动作表尝试它,它就会起作用。我怎样才能使用第二个?
我想在背景中有一个全屏图像。我已经实现了这个:
struct LoginView: View {
var body: some View {
VStack {
Spacer();
Text("Hallo");
Text("Hallo2");
Text("Hallo2");
Text("Hallo2");
Text("Hallo2");
Text("Hallo2");
Text("Hallo2");
Spacer();
}.background(Image("Background LaunchScreen")
.resizable()
.aspectRatio(UIImage(named: "Background LaunchScreen")!.size, contentMode: .fill)
.clipped())
.edgesIgnoringSafeArea(.all)
}
}
Run Code Online (Sandbox Code Playgroud)
当我移除垫片时,图像不再以全屏模式显示。
当然可以用不同的方式解决吗?
如果我将模拟器中的 iPhone 翻到一边,就会出现左右白色条纹。
我怎样才能改变这个?