Home > Blockchain >  set the value of Image to nil SwiftUI
set the value of Image to nil SwiftUI

Time:01-26

I have set a condition to load an SFsymbol.

Image(systemname : isShowList ? "ellipsis" : "")

But I am getting a warning No symbol named ''

How can I set this to an empty value without warning?

CodePudding user response:

It might depend on what is needed in common layout, but possible variants are

a) remove image conditionally

if isShowList {
   Image(systemName : "ellipsis")
}

b) hide image conditionally

Image(systemName : "ellipsis")
  .opacity(isShowList ? 1.0 : 0.0)
  •  Tags:  
  • Related