DSIllustration

@IBDesignable
public final class DSIllustration : UIImageView, DSIconDisplayable

An Anatomy-styled drop-in replacement for a UIImageView designed for (colored) illustration display. For storyboards, add a UIImageView to your view and change the class name to DSIllustration.

Initialize with a rendering type to specify the image displayed. The default intrinsic size is 120x120, but can be overridden by specifying a renderingSize. A rendering size of .size160 would size the illustration at 160x160. It’s recommended not to use layout constraints for sizing.

let defaultIllustration = DSIllustration(renderingType: .office)
let smallIllustration = DSIllustration(renderingType: .quiz, renderingSize: .size160)
let largeIllustration = DSIllustration(renderingType: .tests, renderingSize: .size120)

Do not attempt to change the illustration directly using image as this change could be overwritten if other properties get changed:

let illustration = DSIllustration(renderingType: .gluten)

illustration.image = UIImage(named: "illustration-anatomy-scale")
illustration.renderingSize = .size64 // <-- improper Illustration image will be lost

The rendering type for an DSIllustration can be changed at any time.

Accessors

  • The width and height of the illustration. Illustrations are always square.

    Declaration

    Swift

    public var renderingSize: DSIllustrationRenderingSize { get set }
  • The squared size of the illustration representable by a String.

    This property is only recommended for use in the Attributes inspector of a storyboard since enums are not @IBInspectable. Possible values are 48, 64, and other sizes in IllustrationRenderingSize. In code, use the renderingSize property instead.

    Declaration

    Swift

    @IBInspectable
    public var renderingSizeString: String { get set }
  • The image used by the illustration. Can be changed after initialization.

    Declaration

    Swift

    public var renderingType: DSIllustrationRenderingType { get set }
  • The image used by the illustration representable by a String.

    This property is only recommended for use in the Attributes inspector of a storyboard since enums are not @IBInspectable. Possible values are enumerations of IllustrationRenderingType. In code, use the renderingType property instead.

    Declaration

    Swift

    @IBInspectable
    public var renderingTypeString: String { get set }
  • Returns the name of the rendering type

    Declaration

    Swift

    public var name: String { get }

Initializers