I am trying to overlay some text on an image using Swift and am looking at this code here: (src: How do I add text to an image in iOS Swift)
This places the text right i
Great answer Vasily!
but in my situation I needed to add these fixes.
TEXT IS VERY SMALL
I ran a situation where the text was super small, maybe because the UIImage size was too small for the selected font of 14, so I fixed this by giving a huge font of 120.
TEXT IS NOT DISPLAYED AT THE GIVEN CGPOINT
In the same context of a big UIImage size, the position given to the extension was misplacing the text, the fix: added these 2 lets with the ratio of height and width computed and then multiplied for x,y points.
let widthRatio = size.width/UIScreen.main.bounds.width
let heightRatio = size.height/UIScreen.main.bounds.height
Hope that helps anybody!