UIImageView

extension UIImageView
  • Initialize a UIImageView with image name, target frame, and, optinally, tint color.

    Declaration

    Swift

    public convenience init?(
        withImageNamed imageName: String,
        in frame: CGRect,
        tinted tintColor: UIColor? = nil
    )

    Parameters

    imageName

    Required. Image name to initialize an image view with. If an image with the specified name doesn’t exist, the initializer fails and returns nil.

    frame

    Required. CGRect to draw the image view in.

    tintColor

    Optional. Tint color to use with the image.

  • Initializes a UIImageView with the image retrieved by its name, and, optionally, the image’s dimensions and tint color.

    Declaration

    Swift

    public convenience init?(
        withImageNamed imageName: String,
        width: CGFloat? = nil,
        height: CGFloat? = nil,
        tintColor: UIColor? = nil
    )

    Parameters

    imageName

    Required. The name of the image. Must be a valid name; otherwise, the method will return nil.

    width

    Optional. The width of the image in the UIImageView; defaults to the image’s width.

    height

    Optional. The height of the image in the UIImageView; defaults to the image’s height.

    tintColor

    Optional. The tint color of the image in the UIImageView.