UIImage
public extension UIImage
-
Returns a resized copy of the image, with cornerRadius if used.
Declaration
Swift
func resized(toSize: CGSize, maintainAspectRatio: Bool, useScreenScale: Bool = true, cornerRadius: CGFloat = 0.0, insets: UIEdgeInsets = .zero) -> UIImageParameters
toSizeThe wanted size to fit the new image in.
maintainAspectRatioDetermines if the resulting image will keep the aspect ratio of the original image, If set to true the size of the resulting image will be the closest smaller size to the one specified that maintains the aspect ratio of the original image. If set to false it will stretch the image to fill the size specified.
useScreenScaleDetermines if the screen scale will be used when creating the image context. Default: true. Set to true if you want to make the size relative to the scale of the screen (So the resized image looks the same relative size on all devices, you probably want this if you’re showing the resized image). Set to false if you want the size to be actual pixels (This is useful to generate a resized image of a particular size in real pixels to send to API regardless of the device screen scale).
cornerRadiusThe cornerRadius to be used. Any number lower or equal to zero will not add cornerRadius. Default: 0.0, no corner radius.
-
Returns the aspect ratio of the image represented by a CGFloat. For example an image with a 4:3 ratio will give 1.333… as output.
Declaration
Swift
var aspectRatio: CGFloat { get } -
Returns an image painted with the selected color, so that wherever the image is inserted, it will have that color (the original if color is .none).
Seealso
withRenderingMode(.alwaysOriginal)Declaration
Swift
func tintedWith(_ color: UIColor?) -> UIImageParameters
colorUIColor by which to tint image, or nothing to copy the image as it is.
UIImage Extension Reference