Created
December 5, 2016 15:38
-
-
Save katiesmillie/833c67cd9be8d1603eed9ae9c071e087 to your computer and use it in GitHub Desktop.
UIImage Extension Swift 3 - Change Alpha & Scale / Change Size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extension UIImage { | |
func alpha(value: CGFloat) -> UIImage { | |
let format = UIGraphicsImageRendererFormat() | |
return UIGraphicsImageRenderer(size: size, format: format).image { _ in | |
draw(at: CGPoint.zero, blendMode: .normal, alpha: value) | |
} | |
} | |
func scale(newSize: CGSize) -> UIImage { | |
let format = UIGraphicsImageRendererFormat() | |
return UIGraphicsImageRenderer(size: newSize, format: format).image { _ in | |
draw(at: CGPoint.zero) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment