AlamofireExtension
extension AlamofireExtension where ExtendedType: UIButtonextension AlamofireExtension where ExtendedType: UIImageextension AlamofireExtension where ExtendedType: UIImageView- 
                  
                  The instance image downloader used to download all images. If this property is nil, theUIButtonwill fallback on thesharedImageDownloaderfor all downloads. The most common use case for needing to use a custom instance image downloader is when images are behind different basic auth credentials.DeclarationSwift public var imageDownloader: ImageDownloader? { get nonmutating set }
- 
                  
                  The shared image downloader used to download all images. By default, this is the default ImageDownloaderinstance backed with anAutoPurgingImageCachewhich automatically evicts images from the cache when the memory capacity is reached or memory warning notifications occur. The shared image downloader is only used if theimageDownloaderisnil.DeclarationSwift public static var sharedImageDownloader: ImageDownloader { get set }
- 
                  
                  Asynchronously downloads an image from the specified URL and sets it once the request is finished. If the image is cached locally, the image is set immediately. Otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the image request is finished. DeclarationSwift public func setImage(for state: ControlState, url: URL, cacheKey: String? = nil, placeholderImage: UIImage? = nil, serializer: ImageResponseSerializer? = nil, filter: ImageFilter? = nil, progress: ImageDownloader.ProgressHandler? = nil, progressQueue: DispatchQueue = DispatchQueue.main, completion: ((AFIDataResponse<UIImage>) -> Void)? = nil)ParametersstateThe control state of the button to set the image on. urlThe URL used for your image request. cacheKeyAn optional key used to identify the image in the cache. Defaults to nil.placeholderImageThe image to be set initially until the image request finished. If nil, the image will not change its image until the image request finishes. Defaults tonil.serializerImage response serializer used to convert the image data to UIImage. Defaults tonilwhich will fall back to the instanceimageResponseSerializerset on theImageDownloader.filterThe image filter applied to the image after the image request is finished. Defaults to nil.progressThe closure to be executed periodically during the lifecycle of the request. Defaults to nil.progressQueueThe dispatch queue to call the progress closure on. Defaults to the main queue. completionA closure to be executed when the image request finishes. The closure takes a single response value containing either the image or the error that occurred. If the image was returned from the image cache, the response will be nil. Defaults tonil.
- 
                  setImage(for:urlRequest: cacheKey: placeholderImage: serializer: filter: progress: progressQueue: completion: ) Asynchronously downloads an image from the specified URL and sets it once the request is finished. If the image is cached locally, the image is set immediately. Otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the image request is finished. DeclarationSwift public func setImage(for state: ControlState, urlRequest: URLRequestConvertible, cacheKey: String? = nil, placeholderImage: UIImage? = nil, serializer: ImageResponseSerializer? = nil, filter: ImageFilter? = nil, progress: ImageDownloader.ProgressHandler? = nil, progressQueue: DispatchQueue = DispatchQueue.main, completion: ((AFIDataResponse<UIImage>) -> Void)? = nil)ParametersstateThe control state of the button to set the image on. urlRequestThe URL request. cacheKeyAn optional key used to identify the image in the cache. Defaults to nil.placeholderImageThe image to be set initially until the image request finished. If nil, the image will not change its image until the image request finishes. Defaults tonil.serializerImage response serializer used to convert the image data to UIImage. Defaults tonilwhich will fall back to the instanceimageResponseSerializerset on theImageDownloader.filterThe image filter applied to the image after the image request is finished. Defaults to nil.progressThe closure to be executed periodically during the lifecycle of the request. Defaults to nil.progressQueueThe dispatch queue to call the progress closure on. Defaults to the main queue. completionA closure to be executed when the image request finishes. The closure takes a single response value containing either the image or the error that occurred. If the image was returned from the image cache, the response will be nil. Defaults tonil.
- 
                  
                  Cancels the active download request for the image, if one exists. DeclarationSwift public func cancelImageRequest(for state: ControlState)
- 
                  setBackgroundImage(for:url: cacheKey: placeholderImage: serializer: filter: progress: progressQueue: completion: ) Asynchronously downloads an image from the specified URL and sets it once the request is finished. If the image is cached locally, the image is set immediately. Otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the image request is finished. DeclarationSwift public func setBackgroundImage(for state: ControlState, url: URL, cacheKey: String? = nil, placeholderImage: UIImage? = nil, serializer: ImageResponseSerializer? = nil, filter: ImageFilter? = nil, progress: ImageDownloader.ProgressHandler? = nil, progressQueue: DispatchQueue = DispatchQueue.main, completion: ((AFIDataResponse<UIImage>) -> Void)? = nil)ParametersstateThe control state of the button to set the image on. urlThe URL used for the image request. cacheKeyAn optional key used to identify the image in the cache. Defaults to nil.placeholderImageThe image to be set initially until the image request finished. If nil, the background image will not change its image until the image request finishes. Defaults tonil.serializerImage response serializer used to convert the image data to UIImage. Defaults tonilwhich will fall back to the instanceimageResponseSerializerset on theImageDownloader.filterThe image filter applied to the image after the image request is finished. Defaults to nil.progressThe closure to be executed periodically during the lifecycle of the request. Defaults to nil.progressQueueThe dispatch queue to call the progress closure on. Defaults to the main queue. completionA closure to be executed when the image request finishes. The closure takes a single response value containing either the image or the error that occurred. If the image was returned from the image cache, the response will be nil. Defaults tonil.
- 
                  setBackgroundImage(for:urlRequest: cacheKey: placeholderImage: serializer: filter: progress: progressQueue: completion: ) Asynchronously downloads an image from the specified URL request and sets it once the request is finished. If the image is cached locally, the image is set immediately. Otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the image request is finished. DeclarationSwift public func setBackgroundImage(for state: ControlState, urlRequest: URLRequestConvertible, cacheKey: String? = nil, placeholderImage: UIImage? = nil, serializer: ImageResponseSerializer? = nil, filter: ImageFilter? = nil, progress: ImageDownloader.ProgressHandler? = nil, progressQueue: DispatchQueue = DispatchQueue.main, completion: ((AFIDataResponse<UIImage>) -> Void)? = nil)ParametersstateThe control state of the button to set the image on. urlRequestThe URL request. cacheKeyAn optional key used to identify the image in the cache. Defaults to nil.placeholderImageThe image to be set initially until the image request finished. If nil, the background image will not change its image until the image request finishes. Defaults tonil.serializerImage response serializer used to convert the image data to UIImage. Defaults tonilwhich will fall back to the instanceimageResponseSerializerset on theImageDownloader.filterThe image filter applied to the image after the image request is finished. Defaults to nil.progressThe closure to be executed periodically during the lifecycle of the request. Defaults to nil.progressQueueThe dispatch queue to call the progress closure on. Defaults to the main queue. completionA closure to be executed when the image request finishes. The closure takes a single response value containing either the image or the error that occurred. If the image was returned from the image cache, the response will be nil. Defaults tonil.
- 
                  
                  Cancels the active download request for the background image, if one exists. DeclarationSwift public func cancelBackgroundImageRequest(for state: ControlState)
- 
                  
                  Initializes and returns the image object with the specified data in a thread-safe manner. It has been reported that there are thread-safety issues when initializing large amounts of images simultaneously. In the event of these issues occurring, this method can be used in place of the init?(data:)method.DeclarationSwift public static func threadSafeImage(with data: Data) -> UIImage?ParametersdataThe data object containing the image data. Return ValueAn initialized UIImageobject, ornilif the method failed.
- 
                  
                  Initializes and returns the image object with the specified data and scale in a thread-safe manner. It has been reported that there are thread-safety issues when initializing large amounts of images simultaneously. In the event of these issues occurring, this method can be used in place of the init?(data:scale:)method.DeclarationSwift public static func threadSafeImage(with data: Data, scale: CGFloat) -> UIImage?ParametersdataThe data object containing the image data. scaleThe scale factor to assume when interpreting the image data. Applying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. Return ValueAn initialized UIImageobject, ornilif the method failed.
- 
                  
                  Returns whether the image is inflated. DeclarationSwift public var isInflated: Bool { get nonmutating set }
- 
                  
                  Inflates the underlying compressed image data to be backed by an uncompressed bitmap representation. Inflating compressed image formats (such as PNG or JPEG) can significantly improve drawing performance as it allows a bitmap representation to be constructed in the background rather than on the main thread. DeclarationSwift public func inflate()
- 
                  
                  Returns whether the image contains an alpha component. DeclarationSwift public var containsAlphaComponent: Bool { get }
- 
                  
                  Returns whether the image is opaque. DeclarationSwift public var isOpaque: Bool { get }
- 
                  
                  Returns a new version of the image scaled to the specified size. DeclarationSwift public func imageScaled(to size: CGSize, scale: CGFloat? = nil) -> UIImageParameterssizeThe size to use when scaling the new image. scaleThe scale to set for the new image. Defaults to nilwhich will maintain the current image scale.Return ValueThe new image object. 
- 
                  
                  Returns a new version of the image scaled from the center while maintaining the aspect ratio to fit within a specified size. The resulting image contains an alpha component used to pad the width or height with the necessary transparent pixels to fit the specified size. In high performance critical situations, this may not be the optimal approach. To maintain an opaque image, you could compute the scaledSizemanually, then use theaf.imageScaledToSizemethod in conjunction with a.Centercontent mode to achieve the same visual result.DeclarationSwift public func imageAspectScaled(toFit size: CGSize, scale: CGFloat? = nil) -> UIImageParameterssizeThe size to use when scaling the new image. scaleThe scale to set for the new image. Defaults to nilwhich will maintain the current image scale.Return ValueA new image object. 
- 
                  
                  Returns a new version of the image scaled from the center while maintaining the aspect ratio to fill a specified size. Any pixels that fall outside the specified size are clipped. DeclarationSwift public func imageAspectScaled(toFill size: CGSize, scale: CGFloat? = nil) -> UIImageParameterssizeThe size to use when scaling the new image. scaleThe scale to set for the new image. Defaults to nilwhich will maintain the current image scale.Return ValueA new image object. 
- 
                  
                  Returns a new version of the image with the corners rounded to the specified radius. DeclarationSwift public func imageRounded(withCornerRadius radius: CGFloat, divideRadiusByImageScale: Bool = false) -> UIImageParametersradiusThe radius to use when rounding the new image. divideRadiusByImageScaleWhether to divide the radius by the image scale. Set to truewhen the image has the same resolution for all screen scales such as @1x, @2x and @3x (i.e. single image from web server). Set tofalsefor images loaded from an asset catalog with varying resolutions for each screen scale.falseby default.Return ValueA new image object. 
- 
                  
                  Returns a new version of the image rounded into a circle. DeclarationSwift public func imageRoundedIntoCircle() -> UIImageReturn ValueA new image object. 
- 
                  
                  Returns a new version of the image using a CoreImage filter with the specified name and parameters. DeclarationSwift public func imageFiltered(withCoreImageFilter name: String, parameters: [String : Any]? = nil) -> UIImage?ParametersnameThe name of the CoreImage filter to use on the new image. parametersThe parameters to apply to the CoreImage filter. Return ValueA new image object, or nilif the filter failed for any reason.
- 
                  
                  The instance image downloader used to download all images. If this property is nil, theUIImageViewwill fallback on thesharedImageDownloaderfor all downloads. The most common use case for needing to use a custom instance image downloader is when images are behind different basic auth credentials.DeclarationSwift public var imageDownloader: ImageDownloader? { get nonmutating set }
- 
                  
                  The shared image downloader used to download all images. By default, this is the default ImageDownloaderinstance backed with anAutoPurgingImageCachewhich automatically evicts images from the cache when the memory capacity is reached or memory warning notifications occur. The shared image downloader is only used if theimageDownloaderisnil.DeclarationSwift public static var sharedImageDownloader: ImageDownloader { get set }
- 
                  setImage(withURL:cacheKey: placeholderImage: serializer: filter: progress: progressQueue: imageTransition: runImageTransitionIfCached: completion: ) Asynchronously downloads an image from the specified URL, applies the specified image filter to the downloaded image and sets it once finished while executing the image transition. If the image is cached locally, the image is set immediately. Otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the image request is finished. The completionclosure is called after the image download and filtering are complete, but before the start of the image transition. Please note it is no longer the responsibility of thecompletionclosure to set the image. It will be set automatically. If you require a second notification after the image transition completes, use a.Customimage transition with acompletionclosure. The.Customcompletionclosure is called when the image transition is finished.DeclarationSwift public func setImage(withURL url: URL, cacheKey: String? = nil, placeholderImage: UIImage? = nil, serializer: ImageResponseSerializer? = nil, filter: ImageFilter? = nil, progress: ImageDownloader.ProgressHandler? = nil, progressQueue: DispatchQueue = DispatchQueue.main, imageTransition: UIImageView.ImageTransition = .noTransition, runImageTransitionIfCached: Bool = false, completion: ((AFIDataResponse<UIImage>) -> Void)? = nil)ParametersurlThe URL used for the image request. cacheKeyAn optional key used to identify the image in the cache. Defaults to nil.placeholderImageThe image to be set initially until the image request finished. If nil, the image view will not change its image until the image request finishes. Defaults tonil.serializerImage response serializer used to convert the image data to UIImage. Defaults tonilwhich will fall back to the instanceimageResponseSerializerset on theImageDownloader.filterThe image filter applied to the image after the image request is finished. Defaults to nil.progressThe closure to be executed periodically during the lifecycle of the request. Defaults to nil.progressQueueThe dispatch queue to call the progress closure on. Defaults to the main queue. imageTransitionThe image transition animation applied to the image when set. Defaults to .None.runImageTransitionIfCachedWhether to run the image transition if the image is cached. Defaults to false.completionA closure to be executed when the image request finishes. The closure has no return value and takes three arguments: the original request, the response from the server and the result containing either the image or the error that occurred. If the image was returned from the image cache, the response will be nil. Defaults tonil.
- 
                  setImage(withURLRequest:cacheKey: placeholderImage: serializer: filter: progress: progressQueue: imageTransition: runImageTransitionIfCached: completion: ) Asynchronously downloads an image from the specified URL Request, applies the specified image filter to the downloaded image and sets it once finished while executing the image transition. If the image is cached locally, the image is set immediately. Otherwise the specified placeholder image will be set immediately, and then the remote image will be set once the image request is finished. The completionclosure is called after the image download and filtering are complete, but before the start of the image transition. Please note it is no longer the responsibility of thecompletionclosure to set the image. It will be set automatically. If you require a second notification after the image transition completes, use a.Customimage transition with acompletionclosure. The.Customcompletionclosure is called when the image transition is finished.DeclarationSwift public func setImage(withURLRequest urlRequest: URLRequestConvertible, cacheKey: String? = nil, placeholderImage: UIImage? = nil, serializer: ImageResponseSerializer? = nil, filter: ImageFilter? = nil, progress: ImageDownloader.ProgressHandler? = nil, progressQueue: DispatchQueue = DispatchQueue.main, imageTransition: UIImageView.ImageTransition = .noTransition, runImageTransitionIfCached: Bool = false, completion: ((AFIDataResponse<UIImage>) -> Void)? = nil)ParametersurlRequestThe URL request. cacheKeyAn optional key used to identify the image in the cache. Defaults to nil.placeholderImageThe image to be set initially until the image request finished. If nil, the image view will not change its image until the image request finishes. Defaults tonil.serializerImage response serializer used to convert the image data to UIImage. Defaults tonilwhich will fall back to the instanceimageResponseSerializerset on theImageDownloader.filterThe image filter applied to the image after the image request is finished. Defaults to nil.progressThe closure to be executed periodically during the lifecycle of the request. Defaults to nil.progressQueueThe dispatch queue to call the progress closure on. Defaults to the main queue. imageTransitionThe image transition animation applied to the image when set. Defaults to .None.runImageTransitionIfCachedWhether to run the image transition if the image is cached. Defaults to false.completionA closure to be executed when the image request finishes. The closure has no return value and takes three arguments: the original request, the response from the server and the result containing either the image or the error that occurred. If the image was returned from the image cache, the response will be nil. Defaults tonil.
- 
                  
                  Cancels the active download request, if one exists. DeclarationSwift public func cancelImageRequest()
- 
                  
                  Runs the image transition on the image view with the specified image. DeclarationSwift public func run(_ imageTransition: UIImageView.ImageTransition, with image: Image)ParametersimageTransitionThe image transition to ran on the image view. imageThe image to use for the image transition. 
 View on GitHub
            View on GitHub
           Install in Dash
            Install in Dash
           AlamofireExtension Extension Reference
      AlamofireExtension Extension Reference