Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // String.swift
- // ARKit2d
- //
- // Created by Andrew Seeley on 5/7/17.
- // Copyright © 2017 Seemu. All rights reserved.
- //
- import UIKit
- extension String {
- func image() -> UIImage? {
- let size = CGSize(width: 30, height: 35)
- UIGraphicsBeginImageContextWithOptions(size, false, 0);
- UIColor.clear.set()
- let rect = CGRect(origin: CGPoint(), size: size)
- UIRectFill(CGRect(origin: CGPoint(), size: size))
- (self as NSString).draw(in: rect, withAttributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 30)])
- let image = UIGraphicsGetImageFromCurrentImageContext()
- UIGraphicsEndImageContext()
- return image
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment