I have creating a circle using CGContextFillEllipseInRect
from CoreGraphic
.
I\'m using this circle (which is actually a disk) to replace the <
The problem is that you are creating a non-retina graphics context when using UIGraphicsBeginImageContext
, as mentioned in the documentation:
This function is equivalent to calling the
UIGraphicsBeginImageContextWithOptions
function with the opaque parameter set toNO
and a scale factor of1.0
.
Instead you should be using UIGraphicsBeginImageContextWithOptions
to create your image context. You can keep passing NO
for the opaque parameter if you want an image that supports transparency (same as what you are implicitly doing now).
In most cases you can pass 0.0
for the scale factor. This sets the scale factor to that of the device's main screen. Again, as mentioned in the documentation:
If you specify a value of
0.0
, the scale factor is set to the scale factor of the device’s main screen.
So, in short, you should create your image context like this:
UIGraphicsBeginImageContextWithOptions(rectForDisk.size, false, 0.0) // false for Swift