Skip to content

Instantly share code, notes, and snippets.

@jrturton
Created November 19, 2018 14:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrturton/6fca819816f7039701b877f03d2f087a to your computer and use it in GitHub Desktop.
Save jrturton/6fca819816f7039701b877f03d2f087a to your computer and use it in GitHub Desktop.
Make a date-stamped test image
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