mirror of https://github.com/oxen-io/session-ios
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
	
	
		
			17 lines
		
	
	
		
			645 B
		
	
	
	
		
			Swift
		
	
		
		
			
		
	
	
			17 lines
		
	
	
		
			645 B
		
	
	
	
		
			Swift
		
	
| 
											5 years ago
										 | 
 | ||
|  | @objc(LKIdenticon) | ||
|  | public final class Identicon : NSObject { | ||
|  |      | ||
|  |     @objc public static func generatePlaceholderIcon(seed: String, text: String, size: CGFloat) -> UIImage { | ||
|  |         let icon = PlaceholderIcon(seed: seed) | ||
| 
											5 years ago
										 |         var content = text | ||
|  |         if content.count > 2 && content.hasPrefix("05") { | ||
|  |             content.removeFirst(2) | ||
|  |         } | ||
|  |         let layer = icon.generateLayer(with: size, text: content.substring(to: 1)) | ||
| 
											5 years ago
										 |         let rect = CGRect(origin: CGPoint.zero, size: layer.frame.size) | ||
|  |         let renderer = UIGraphicsImageRenderer(size: rect.size) | ||
|  |         return renderer.image { layer.render(in: $0.cgContext) } | ||
|  |     } | ||
|  | } |