EnterpriseDS Documentation

Class DSIcon

@IBDesignable public final class DSIcon: UIImageView, DSIconDisplayable  

An Enterprise-styled drop-in replacement for a UIImageView that displays a standard Enterprise icon (DSIconRenderingType).

For storyboards, add a UIImageView to your view and change the class name to DSIcon.

Initialize with a rendering type to specify the image displayed. The default intrinsic size is 20x20, but can be overridden by specifying a renderingSize. A rendering size of .size24 would size the icon at 24x24. It's recommended not to use layout constraints for sizing.

let defaultIcon = DSIcon(renderingType: .airplane_outline)
defaultIcon.tintColor = .grayscaleBlack

let smallIcon = DSIcon(renderingType: .print_outline, renderingSize: .size20)
smallIcon.tintColor = .grayscaleBlack
let largeIcon = DSIcon(renderingType: .envelope_outline, renderingSize: .size24)
largeIcon.tintColor = .grayscaleBlack

Icons have a default black tint and it's recommended that you specify one. Do not attempt to change the icon directly using image as this change could be overwritten if other properties get changed:

let icon = DSIcon(renderingType: .none)

icon.image = UIImage(named: "my-own-image-specified")
icon.renderingSize = .size20 // <-- improper Icon image will be lost

No tintColor is applied by DSIcon. The rendering type for a DSIcon can be changed at any time.

DSIcon DSIcon DSIconDisplayable DSIconDisplayable DSIcon->DSIconDisplayable UIImageView UIImageView DSIcon->UIImageView

Conforms To

UIImageView

Initializers

init(rendering​Type:​)

public init(renderingType: DSIconRenderingType)  

Initializes and returns a newly allocated DSIcon with the specified renderingType.

Parameters

rendering​Type DSIcon​Rendering​Type

The renderingType to style the component.

init(rendering​Type:​rendering​Size:​)

public init(renderingType: DSIconRenderingType, renderingSize: DSIconRenderingSize)  

Initializes and returns a newly allocated Icon with the specified renderingType.

Parameters

rendering​Type DSIcon​Rendering​Type

The renderingType to style the component.

rendering​Size DSIcon​Rendering​Size

The renderingSize to style the component.

Properties

rendering​Size

public var renderingSize: DSIconRenderingSize = .size20  

The width and height of the icon. Icons are always square.

rendering​Size​String

@IBInspectable public var renderingSizeString: String  

The squared size of the icon 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 16, 24, and other sizes in IconRenderingSize. In code, use the renderingSize property instead.

rendering​Type

public var renderingType: DSIconRenderingType = .none  

The image used by the icon. Can be changed after initialization.

rendering​Type​String

@IBInspectable public var renderingTypeString: String  

The image used by the icon 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 IconRenderingType. In code, use the renderingType property instead.

name

public var name: String  

Returns the name of the rendering type

intrinsic​Content​Size

public override var intrinsicContentSize: CGSize  

Methods

prepare​For​Interface​Builder()

public override func prepareForInterfaceBuilder()