How do I turn antialiasing on or off in a SwiftUI Canvas?
struct CanvasView: View {
var body: some View {
Canvas { context, size in
// CGContextSetShouldAntialias(context, false);
}
}
}
How do I turn antialiasing on or off in a SwiftUI Canvas?
struct CanvasView: View {
var body: some View {
Canvas { context, size in
// CGContextSetShouldAntialias(context, false);
}
}
}
There is no "global" switch in
GraphicsContextthat turns antialiasing on and off. Instead antialiasing can be controlled individually for each draw operation that takes aFillStyle. You can specify whether you want antialiasing when creating theFillStyle.For example:
Otherwise, you can always get a
CGContextand work with theCGContextAPIs instead.The stroking APIs don't take a
FillStyle, so if you want to configure antialiasing for those, you will need to use theCGContextAPIs, or convert the stroking operation to a fill operation, by usingstrokedPath: