Вi
ViewController: UIViewController {
@IBOutlet@IBOutlet
weak
var imageView: UIImageView!
override
func viewDidLoad() {
super.viewDidLoad()
UIGraphicsBeginImageContext(
self.view.bounds.size)
guard
let context = UIGraphicsGetCurrentContext()
else {
return }
context.setFillColor(UIColor.yellow.cgColor)
let rectangle = CGRect(x: 100,
y: 100,
width: 100,
height: 100)
context.addEllipse(in: rectangle)
let font = UIFont.systemFont(ofSize: 50)
let string = NSAttributedString(string: "23", attributes: [NSAttributedString.Key.font: font,
NSAttributedString.Key.strokeColor: UIColor.yellow,
NSAttributedString.Key.underlineColor: UIColor.white,
NSAttributedString.Key.strikethroughColor: UIColor.purple,
NSAttributedString.Key.backgroundColor: UIColor.red,
NSAttributedString.Key.foregroundColor: UIColor.green
])
string.draw(at: CGPoint(x: rectangle.minX + rectangle.width / 2 - 50 / 4,
y: rectangle.minY + rectangle.height / 2 - 40))
context.fillPath()
imageView.image = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
}
}