Я застрял в этой проблеме с пользовательским интерфейсом, работая с SwiftUI и UIView.
По сути, оверлей останавливает взаимодействие с пользователем, чтобы выполнить UIView.
Button(action: { print("hello") }){ Text("HERE") }
.overlay(
LinearGradient(
gradient: Gradient(colors: [.clear, Color.black.opacity(0.3)]),
startPoint: .top,
endPoint: .bottom
).allowsHitTesting(false))
Не работает с UIView
struct ButtonView: UIViewRepresentable {
func makeUIView(context: Context) -> UIButton {
return UIButton(type: .close)
}
func updateUIView(_ uiView: UIButton, context: Context) {
}
}
ButtonView()
.overlay(
LinearGradient(
gradient: Gradient(colors: [.clear, Color.black.opacity(0.3)]),
startPoint: .top,
endPoint: .bottom
).allowsHitTesting(false))
У кого-нибудь возникают такие же проблемы? Спасибо!