I tried to implement lock/unlock button, but it was hard to make. In my case, I used two Image. One is Rectangle with a lock, another is just a rectangle. And using ZStack, made them as a one button.
// mincho
import SwiftUI
struct ZStackView: View {
var clearInfoData : ClearInfo
var body: some View {
ZStack{
NavigationLink(destination: HonorDetailView(clearInfo: clearInfoData).toolbar{
Button(action: {
}, label: {
Image(systemName: "square.and.arrow.up")
})
}) {
Image(clearInfoData.clearImage)
.resizable()
.frame(width: 100, height: 100)
}.zIndex(data) // when stage cleared, data will change 0 to 1.
Image("LockedRectangle")
}
}
struct ZStackView_Previews: PreviewProvider {
static var previews: some View {
ZStackView(clearInfoData: cleardata[0].clearInfo[1])
}
}
Like this, Image + NavigationLink -> as a Button. So when stage cleared, this button show unlock image and working navigation view. And I want to control button's opacity when it clicked.
In my guess, button's opacity going lower when i click. However I want that button keep opaque.
- Is it exist other better way to make unlock/lock button?
- If it is best way, what should I do to make this button opaque?