我有一个AttributedString
,在UI中有一个链接,如下所示:
结构内容视图:查看{
private let attributedString: AttributedString = {
var attributedString = AttributedString("Notifications disabled. Please enable them in Settings.")
attributedString.foregroundColor = .black
if let range = attributedString.range(of: "Settings") {
attributedString[range].foregroundColor = .blue
attributedString[range].link = .init(string: UIApplication.openSettingsURLString)
}
return attributedString
}()
var body: some View {
ZStack {
Color.white
.ignoresSafeArea()
.onTapGesture {
print("Tapped")
}
Text(attributedString)
}
}
由于某种原因,onTapGesture
阻止了点击手势的发生。我也不能选择将点击手势移动到ZStack
,因为这会阻止主应用中的其他手势。我该如何解决这个问题?
1条答案
按热度按时间agxfikkp1#
你可以试试这个