RoundCornerImageProcessor

public struct RoundCornerImageProcessor : ImageProcessor

Processor for making round corner images. Only CG-based images are supported in macOS, if a non-CG image passed in, the processor will do nothing.

Note

The input image will be rendered with round corner pixels removed. If the image itself does not contain alpha channel (for example, a JPEG image), the processed image will contain an alpha channel in memory in order to show correctly. However, when cached to disk, Kingfisher respects the original image format by default. That means the alpha channel will be removed for these images. When you load the processed image from cache again, you will lose transparent corner.

You could use FormatIndicatedCacheSerializer.png to force Kingfisher to serialize the image to PNG format in this case.

  • Represents a radius specified in a RoundCornerImageProcessor.

    See more

    Declaration

    Swift

    public enum Radius
  • Identifier of the processor.

    Note

    See documentation of ImageProcessor protocol for more.

    Declaration

    Swift

    public let identifier: String
  • Corner radius will be applied in processing. To provide backward compatibility, this property returns 0 unless Radius.point is specified.

    Declaration

    Swift

    @available(*, deprecated, message: "Use `radius` property instead.")
    public var cornerRadius: CGFloat { get }
  • The radius will be applied in processing. Specify a certain point value with .point, or a fraction of the target image with .fraction. .fraction(0.5) means use half of the

    Declaration

    Swift

    public let radius: Radius
  • The target corners which will be applied rounding.

    Declaration

    Swift

    public let roundingCorners: RectCorner
  • Target size of output image should be. If nil, the image will keep its original size after processing.

    Declaration

    Swift

    public let targetSize: CGSize?
  • Background color of the output image. If nil, it will use a transparent background.

    Declaration

    Swift

    public let backgroundColor: KFCrossPlatformColor?
  • Creates a RoundCornerImageProcessor.

    Note

    Note:

    This initializer accepts a concrete point value for cornerRadius. If you do not know the image size, but still want to apply a full round-corner (making the final image a round one), or specify the corner radius as a fraction of one dimension of the target image, use the Radius version instead.

    Declaration

    Swift

    public init(
        cornerRadius: CGFloat,
        targetSize: CGSize? = nil,
        roundingCorners corners: RectCorner = .all,
        backgroundColor: KFCrossPlatformColor? = nil
    )

    Parameters

    cornerRadius

    Corner radius in point will be applied in processing.

    targetSize

    Target size of output image should be. If nil, the image will keep its original size after processing. Default is nil.

    corners

    The target corners which will be applied rounding. Default is .all.

    backgroundColor

    Background color to apply for the output image. Default is nil.

  • Creates a RoundCornerImageProcessor.

    Declaration

    Swift

    public init(
        radius: Radius,
        targetSize: CGSize? = nil,
        roundingCorners corners: RectCorner = .all,
        backgroundColor: KFCrossPlatformColor? = nil
    )

    Parameters

    radius

    The radius will be applied in processing.

    targetSize

    Target size of output image should be. If nil, the image will keep its original size after processing. Default is nil.

    corners

    The target corners which will be applied rounding. Default is .all.

    backgroundColor

    Background color to apply for the output image. Default is nil.

  • Processes the input ImageProcessItem with this processor.

    Note

    See documentation of ImageProcessor protocol for more.

    Declaration

    Swift

    public func process(item: ImageProcessItem, options: KingfisherParsedOptionsInfo) -> KFCrossPlatformImage?

    Parameters

    item

    Input item which will be processed by self.

    options

    Options when processing the item.

    Return Value

    The processed image.