Class
DSIllustration
@IBDesignable public final class DSIllustration: UIImageView, DSIconDisplayable
An Enterprise-styled drop-in replacement for a UIImageView that displays a standard Enterprise illustration (DSIllustrationRenderingType).
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-enterprise-scale")
illustration.renderingSize = .size64 // <-- improper Illustration image will be lost
The rendering type for an DSIllustration can be changed at any time.
Relationships
Conforms To
UIImageView
Initializers
init(renderingType:renderingSize:)
public init(renderingType: DSIllustrationRenderingType, renderingSize: DSIllustrationRenderingSize)
Initializes and returns a newly allocated DSIllustration with the specified renderingType.
Parameters
Name | Type | Description |
---|---|---|
renderingType | DSIllustrationRenderingType |
The renderingType to style the component. |
renderingSize | DSIllustrationRenderingSize |
The renderingSize to style the component. |
Properties
renderingSize
public var renderingSize: DSIllustrationRenderingSize = .size120
The width and height of the illustration. Illustrations are always square.
renderingSizeString
@IBInspectable public var renderingSizeString: String
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.
renderingType
public var renderingType: DSIllustrationRenderingType = .none
The image used by the illustration. Can be changed after initialization.
renderingTypeString
@IBInspectable public var renderingTypeString: String
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.
intrinsicContentSize
public override var intrinsicContentSize: CGSize
Methods
prepareForInterfaceBuilder()
public override func prepareForInterfaceBuilder()