Hidden
modifier is used to hide views. Views that are hidden are invisible and don’t receive or respond to the interactions but they remain in view hierarchy and take the space in layout.
Let’s put together an example. We will start with HStack
and four Image
views.
struct DevTechieHiddenExample: View {
var body: some View {
VStack(spacing: 20) {
Text("DevTechie")
.font(.largeTitle)
.foregroundColor(.orange)
HStack {
Image(systemName: "a.circle.fill")
Image(systemName: "b.circle.fill")
Image(systemName: "c.circle.fill")
Image(systemName: "d.circle.fill")
}
.font(.largeTitle)
}
}
}
Let’s apply hidden modifier to letter B.
Image(systemName: "b.circle.fill").hidden()
Notice that the view is gone but its place is still taken up by the hidden view, this mean that even though the view is not present but…