Created
November 19, 2018 14:59
-
-
Save jrturton/6fca819816f7039701b877f03d2f087a to your computer and use it in GitHub Desktop.
Make a date-stamped test image
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let renderer = UIGraphicsImageRenderer(size: CGSize(width: 400, height: 400)) | |
let image = renderer.image { | |
context in | |
UIColor.lightGray.setFill() | |
UIRectFill(context.format.bounds) | |
UIColor.black.set() | |
UIRectFrame(context.format.bounds) | |
let text = "TEST IMAGE \n\(Date())" as NSString | |
let paragraph = NSMutableParagraphStyle() | |
paragraph.alignment = .center | |
text.draw(in: context.format.bounds.offsetBy(dx: 0, dy: 75), withAttributes: [.paragraphStyle: paragraph, .font: UIFont.systemFont(ofSize: 60)]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment