Hello, I am trying to custom draw the .accessoryInline
lock screen widget. When I return a Label() from a widget View, like this Label("Snow", systemImage: "snow")
, the icon draws just fine, but once I try to draw my own icon, the icon doesn't show.
My drawing code (simplified):
public struct IconTestView: View {
private func makePath(size: CGSize) -> UIBezierPath {
let path = UIBezierPath()
path.move(to: CGPoint(x: size.width * 0.5, y: 0))
path.addLine(to: CGPoint(x: size.width, y: size.height * 0.5))
path.addLine(to: CGPoint(x: size.width * 0.5, y: size.height))
path.addLine(to: CGPoint(x: 0, y: size.height * 0.5))
path.addLine(to: CGPoint(x: size.width * 0.5, y: 0))
path.close()
return path
}
public var body: some View {
GeometryReader { geo in
Path(
makePath(size: geo.size).cgPath
)
.stroke(
.white,
style: StrokeStyle(lineWidth: 2.0, lineCap: .round, lineJoin: .round)
)
.frame(width: geo.size.width, height: geo.size.height)
} /// geo
.frame(idealWidth: .infinity, maxWidth: .infinity, idealHeight: .infinity, maxHeight: .infinity)
}
}
My widget then looks like this:
var body: some View {
Label {
Text("Hello world")
} icon: {
IconTestView()
}
}
The IconTestView()
draws a diamond shape inside .accessoryCircular
just fine, but nothing is drawn in .accessoryInline
when I return the above label.
Is this scenario just not supported (= I can only pick the icon out of SF symbols), or is there a way to do this?