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 into disk, the image format will be respected and the alpha channel will
be removed. That means 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.
-
Identifier of the processor.
Note
See documentation ofImageProcessor
protocol for more.Declaration
Swift
public let identifier: String
-
Corner radius will be applied in processing.
Declaration
Swift
public let cornerRadius: CGFloat
-
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: Color?
-
Creates a
RoundCornerImageProcessor
.Declaration
Swift
public init( cornerRadius: CGFloat, targetSize: CGSize? = nil, roundingCorners corners: RectCorner = .all, backgroundColor: Color? = nil)
Parameters
cornerRadius
Corner 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 isnil
.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) -> Image?
Parameters
item
Input item which will be processed by
self
.options
Options when processing the item.
Return Value
The processed image.