【发布时间】:2021-05-31 08:52:58
【问题描述】:
所以我是 Swift 的新手,这可能是一个相当愚蠢的问题。但是,我正在寻找一种在用户按下按钮时更新按钮Image(systemName) 的方法。我在网上找到了一些例子,但我很难掌握UIButton 和Button 的概念。
我的当前按钮
// lock State (Set in struct ContentView: View)
@State var isViewLocked:Bool = false
// View Lock Button
Button(action: {
isViewLocked.toggle()
}, label: {
Image(systemName: "lock")
.font(.system(size: 25,
weight: .regular,
design: .default))
.foregroundColor(selectedIndex == number ? Color(.systemBlue) : Color(UIColor.lightGray))
})
提前致谢。
【问题讨论】: