Kingfisher

Undocumented

  • Normalize the image. This method does nothing in OS X.

  • Normalize the image. This method will try to redraw an image with orientation and scale considered.

    Declaration

    Swift

    public var normalized: Image

    Return Value

    The normalized image with orientation set to up and correct scale.

  • Create a round corner image based on self.

    Note

    This method only works for CG-based image.

    Declaration

    Swift

    public func image(withRoundRadius radius: CGFloat,
                          fit size: CGSize,
                          roundingCorners corners: RectCorner = .all,
                          backgroundColor: Color? = nil) -> Image

    Parameters

    radius

    The round corner radius of creating image.

    size

    The target size of creating image.

    corners

    The target corners which will be applied rounding.

    backgroundColor

    The background color for the output image

    Return Value

    An image with round corner of self.

  • Resize self to an image of new size.

    Note

    This method only works for CG-based image.

    Declaration

    Swift

    public func resize(to size: CGSize) -> Image

    Parameters

    size

    The target size.

    Return Value

    An image with new size.

  • Resize self to an image of new size, respecting the content mode.

    Declaration

    Swift

    public func resize(to size: CGSize, for contentMode: ContentMode) -> Image

    Parameters

    size

    The target size.

    contentMode

    Content mode of output image should be.

    Return Value

    An image with new size.

  • Undocumented

  • Create an image with blur effect based on self.

    Note

    This method only works for CG-based image.

    Declaration

    Swift

    public func blurred(withRadius radius: CGFloat) -> Image

    Parameters

    radius

    The blur radius should be used when creating blur effect.

    Return Value

    An image with blur effect applied.

  • Create an image from self with a color overlay layer.

    Note

    This method only works for CG-based image.

    Declaration

    Swift

    public func overlaying(with color: Color, fraction: CGFloat) -> Image

    Parameters

    color

    The color should be use to overlay.

    fraction

    Fraction of input color. From 0.0 to 1.0. 0.0 means solid color, 1.0 means transparent overlay.

    Return Value

    An image with a color overlay applied.

  • Create an image from self with a color tint.

    Declaration

    Swift

    public func tinted(with color: Color) -> Image

    Parameters

    color

    The color should be used to tint self

    Return Value

    An image with a color tint applied.

  • Create an image from self with color control.

    Declaration

    Swift

    public func adjusted(brightness: CGFloat, contrast: CGFloat, saturation: CGFloat, inputEV: CGFloat) -> Image

    Parameters

    brightness

    Brightness changing to image.

    contrast

    Contrast changing to image.

    saturation

    Saturation changing to image.

    inputEV

    InputEV changing to image.

    Return Value

    An image with color control applied.

  • Return an image with given scale.

    Declaration

    Swift

    public func scaled(to scale: CGFloat) -> Image

    Parameters

    scale

    Target scale factor the new image should have.

    Return Value

    The image with target scale. If the base image is already in the scale, base will be returned.

  • Apply a Filter containing CIImage transformer to self.

    Note

    Only CG-based images are supported. If any error happens during transforming, self will be returned.

    Declaration

    Swift

    public func apply(_ filter: Filter) -> Image

    Parameters

    filter

    The filter used to transform self.

    Return Value

    A transformed image by input Filter.

  • Set an image with a resource, a placeholder image, options, progress handler and completion handler.

    Note

    Both the progressBlock and completionHandler will be invoked in main thread. The CallbackDispatchQueue specified in optionsInfo will not be used in callbacks of this method.

    If resource is nil, the placeholder image will be set and completionHandler will be called with both error and image being nil.

    Declaration

    Swift

    public func setImage(with resource: Resource?,
                             placeholder: Placeholder? = nil,
                             options: KingfisherOptionsInfo? = nil,
                             progressBlock: DownloadProgressBlock? = nil,
                             completionHandler: CompletionHandler? = nil) -> RetrieveImageTask

    Parameters

    resource

    Resource object contains information such as cacheKey and downloadURL.

    placeholder

    A placeholder image when retrieving the image at URL.

    options

    A dictionary could control some behaviors. See KingfisherOptionsInfo for more.

    progressBlock

    Called when the image downloading progress gets updated.

    completionHandler

    Called when the image retrieved and set.

    Return Value

    A task represents the retrieving process.

  • Cancel the image download task bounded to the image view if it is running. Nothing will happen if the downloading has already finished.

    Declaration

    Swift

    public func cancelDownloadTask()
  • Set an image to use for a specified state with a resource, a placeholder image, options, progress handler and completion handler.

    Note

    Both the progressBlock and completionHandler will be invoked in main thread. The CallbackDispatchQueue specified in optionsInfo will not be used in callbacks of this method.

    If resource is nil, the placeholder image will be set and completionHandler will be called with both error and image being nil.

    Declaration

    Swift

    public func setImage(with resource: Resource?,
                             for state: UIControlState,
                             placeholder: UIImage? = nil,
                             options: KingfisherOptionsInfo? = nil,
                             progressBlock: DownloadProgressBlock? = nil,
                             completionHandler: CompletionHandler? = nil) -> RetrieveImageTask

    Parameters

    resource

    Resource object contains information such as cacheKey and downloadURL.

    state

    The state that uses the specified image.

    placeholder

    A placeholder image when retrieving the image at URL.

    options

    A dictionary could control some behaviors. See KingfisherOptionsInfo for more.

    progressBlock

    Called when the image downloading progress gets updated.

    completionHandler

    Called when the image retrieved and set.

    Return Value

    A task represents the retrieving process.

  • Cancel the image download task bounded to the image view if it is running. Nothing will happen if the downloading has already finished.

    Declaration

    Swift

    public func cancelImageDownloadTask()
  • Set the background image to use for a specified state with a resource, a placeholder image, options progress handler and completion handler.

    Note

    Both the progressBlock and completionHandler will be invoked in main thread. The CallbackDispatchQueue specified in optionsInfo will not be used in callbacks of this method.

    If resource is nil, the placeholder image will be set and completionHandler will be called with both error and image being nil.

    Declaration

    Swift

    public func setBackgroundImage(with resource: Resource?,
                                       for state: UIControlState,
                                       placeholder: UIImage? = nil,
                                       options: KingfisherOptionsInfo? = nil,
                                       progressBlock: DownloadProgressBlock? = nil,
                                       completionHandler: CompletionHandler? = nil) -> RetrieveImageTask

    Parameters

    resource

    Resource object contains information such as cacheKey and downloadURL.

    state

    The state that uses the specified image.

    placeholder

    A placeholder image when retrieving the image at URL.

    options

    A dictionary could control some behaviors. See KingfisherOptionsInfo for more.

    progressBlock

    Called when the image downloading progress gets updated.

    completionHandler

    Called when the image retrieved and set.

    Return Value

    A task represents the retrieving process.

  • Cancel the background image download task bounded to the image view if it is running. Nothing will happen if the downloading has already finished.

    Declaration

    Swift

    public func cancelBackgroundImageDownloadTask()
  • Get the image URL binded to this button for a specified state.

    Declaration

    Swift

    public func webURL(for state: UIControlState) -> URL?

    Parameters

    state

    The state that uses the specified image.

    Return Value

    Current URL for image.

  • Get the background image URL binded to this button for a specified state.

    Declaration

    Swift

    public func backgroundWebURL(for state: UIControlState) -> URL?

    Parameters

    state

    The state that uses the specified background image.

    Return Value

    Current URL for background image.