Guest User

Untitled

a guest
Jul 7th, 2017
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Swift 0.71 KB | None | 0 0
  1. //
  2. //  String.swift
  3. //  ARKit2d
  4. //
  5. //  Created by Andrew Seeley on 5/7/17.
  6. //  Copyright © 2017 Seemu. All rights reserved.
  7. //
  8.  
  9. import UIKit
  10.  
  11. extension String {
  12.    
  13.     func image() -> UIImage? {
  14.         let size = CGSize(width: 30, height: 35)
  15.         UIGraphicsBeginImageContextWithOptions(size, false, 0);
  16.         UIColor.clear.set()
  17.         let rect = CGRect(origin: CGPoint(), size: size)
  18.         UIRectFill(CGRect(origin: CGPoint(), size: size))
  19.         (self as NSString).draw(in: rect, withAttributes: [NSAttributedStringKey.font: UIFont.systemFont(ofSize: 30)])
  20.         let image = UIGraphicsGetImageFromCurrentImageContext()
  21.         UIGraphicsEndImageContext()
  22.         return image
  23.     }
  24.    
  25. }
Advertisement
Add Comment
Please, Sign In to add comment