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.
		
		
		
		
		
			
		
			
				
	
	
		
			31 lines
		
	
	
		
			800 B
		
	
	
	
		
			Swift
		
	
			
		
		
	
	
			31 lines
		
	
	
		
			800 B
		
	
	
	
		
			Swift
		
	
//
 | 
						|
//  Copyright (c) 2018 Open Whisper Systems. All rights reserved.
 | 
						|
//
 | 
						|
 | 
						|
import Foundation
 | 
						|
 | 
						|
extension UIImage {
 | 
						|
 | 
						|
    private func image(with view: UIView) -> UIImage? {
 | 
						|
        UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.isOpaque, 0.0)
 | 
						|
        defer { UIGraphicsEndImageContext() }
 | 
						|
 | 
						|
        guard let context = UIGraphicsGetCurrentContext() else {
 | 
						|
            return nil
 | 
						|
        }
 | 
						|
 | 
						|
        view.layer.render(in: context)
 | 
						|
        let image = UIGraphicsGetImageFromCurrentImageContext()
 | 
						|
        return image
 | 
						|
    }
 | 
						|
 | 
						|
    @objc
 | 
						|
    public func asTintedImage(color: UIColor) -> UIImage? {
 | 
						|
        let template = self.withRenderingMode(.alwaysTemplate)
 | 
						|
        let imageView = UIImageView(image: template)
 | 
						|
        imageView.tintColor = color
 | 
						|
 | 
						|
        return image(with: imageView)
 | 
						|
    }
 | 
						|
}
 |