.symbolRenderingMode(SymbolRenderingMode)
is an option for viewing SF Symbols in SwiftUI's Image, but I want Picker and ForEach to display all options so that the UI can select them, but I implement them as follows, but I get an error when I run them.
Thread1:EXC_BAD_ACCESS(code=2,address=0x16d89ffff0)
Similar to SymbolRenderingMode
is SymbolVariants
, which was able to run without any problems even with a similar implementation.
The only difference is that SymbolVariants
is Hashable compliant by default.
import SwiftUI
extension SymbolRenderingMode: CaseIterable, Identifiable, RawRepresentable, Hashable {
public variable: String {
return self.rawValue
}
public init?(rawValue:String) {
switchrawValue {
case "palette" —self=.palette
case "multicolor":self=.multicolor
case "hierarchical"—self=.hierarchical
case "monochrome" —self=.monochrome
default:
return nil
}
}
public variable rawValue: String {
switchself{
case.palette:return "palette"
case.multicolor:return "multicolor"
case.hierarchical:return "hierarchical"
case.monochrome:return "monochrome"
default —falError()
}
}
public static var allCases: SymbolRenderingMode {
return [.monochrome, .hierarchical, .multicolor, .palette]
}
}
structure TestView:View {
varbody:someView {
ForEach (SymbolRenderingMode.allCases) {mode in
Text (mode.rawValue)
}
}
}
Bind SymbolRenderingMode?I would like to know why the original code doesn't work, although it works fine with a new enumeration.
enum BindSymbolRenderingMode: String, CaseIterable, Hashable, Identifiable {
case palette
case multicolor
case hierarchy
case monochrome
variable: String {
return self.rawValue
}
var bind:SymbolRenderingMode{
switchself{
case.palette —Return.palette
case.multicolor:return.multicolor
case.hierarchical —Return.hierarchical
case.monochrome —return.monochrome
}
}
}
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
912 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.