Name: ImageHelper
Owner: Wantedly, Inc.
Description: Convenience extension for UIImage and UIImageView in Swift
Forked from: melvitax/ImageHelper
Created: 2017-01-17 02:27:41.0
Updated: 2017-01-17 02:27:44.0
Pushed: 2017-01-17 02:31:45.0
Homepage: null
Size: 1627
Language: Swift
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Image Extensions for Swift 3.0
To run the example project, clone or download the repo, and run.
etches an image from a URL. If caching is set, it will be cached by NSCache for future queries. The cached image is returned if available, otherise the placeholder is set. When the image is returned, the closure gets called.
imageFromURL(url: String, placeholder: UIImage, fadeIn: Bool = true, closure: ((image: UIImage?)
reates an image from a solid color
age(color:UIColor, size:CGSize)
reates an image from a gradient color
age(gradientColors:[UIColor], size:CGSize)
pplies a gradient overlay to an image
applyGradientColors(gradientColors: [UIColor], blendMode: CGBlendMode) -> UIImage
reates an image from a radial gradient
age(startColor: UIColor, endColor: UIColor, radialGradientCenter: CGPoint, radius:Float, size:CGSize)
reates an image with a string of text
age(text: String, font: UIFont, color: UIColor, backgroundColor: UIColor, size:CGSize, offset: CGPoint)
reates an image from a UIView
age(fromView view: UIView)
eturns true if the image has an alpha layer
hasAlpha() -> Bool
eturns a copy(if needed) of the image with alpha layer
applyAlpha() -> UIImage?
eturns a copy of the image with a transparent border of the given size added around its edges
applyPadding(padding: CGFloat) -> UIImage?
rops an image to a new rect
crop(bounds: CGRect) -> UIImage?
rops an image to a centered square
cropToSquare() -> UIImage? {
esizes an image
resize(size:CGSize, contentMode: UIImageContentMode = .ScaleToFill) -> UIImage?
ounds corners of an image
roundCorners(cornerRadius:CGFloat) -> UIImage?
ounds corners of an image with border
roundCorners(cornerRadius:CGFloat, border:CGFloat, color:UIColor) -> UIImage?
ounds corners to a circle
roundCornersToCircle() -> UIImage?
ounds corners to a circle with border
roundCornersToCircle(border border:CGFloat, color:UIColor) -> UIImage?
dds a border
applyBorder(border:CGFloat, color:UIColor) -> UIImage?
pplies a light blur effect to the image
applyLightEffect() -> UIImage?
pplies a extra light blur effect to the image
applyExtraLightEffect() -> UIImage?
pplies a dark blur effect to the image
applyDarkEffect() -> UIImage?
pplies a color tint to an image
applyTintEffect(tintColor: UIColor) -> UIImage?
pplies a blur to an image based on the specified radius, tint color saturation and mask image
applyBlur(blurRadius:CGFloat, tintColor:UIColor?, saturationDeltaFactor:CGFloat, maskImage:UIImage? = nil) -> UIImage?
o create an image that is Retina aware, use the screen scale as a multiplier for your size. You should also use this technique for padding or borders.
width = 140 * UIScreen.mainScreen().scale
height = 140 * UIScreen.mainScreen().scale
image = UIImage(named: "myImage")?.resize(CGSize(width: width, height: height))