ImageRenderer()
ImageRenderer () is a SwiftUI class that creates an image from a view. You just initialize it with the view, then extract a cgImage (Core Graphics) or uiImage that can be cast to a SwiftUI Image.
I’ll need a view to work with, so here it is; a crude version of my behaviour ticket.
struct TicketView: View {
var body: some View {
ZStack {
Color(.cyan)
.frame(width: 300, height: 350)
VStack {
Text("Fred Bloggs")
.font(.largeTitle)
Text("")
HStack {
Text("Putting rubbish in the bin")
Image(systemName: "trash")
}
.foregroundColor(.purple)
Text("")
Text("Green Faction")
Text("")
Text("")
Text("\(Date().formatted())")
}
}
}
}
Here it is, with a couple of buttons underneath:

