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.
Relationships
Conforms To
UIImageView
Initializers
init(renderingType:)
public init(renderingType: DSIconRenderingType)
Initializes and returns a newly allocated DSIcon with the specified renderingType.
Parameters
Name | Type | Description |
---|---|---|
renderingType | DSIconRenderingType |
The renderingType to style the component. |
init(renderingType:renderingSize:)
public init(renderingType: DSIconRenderingType, renderingSize: DSIconRenderingSize)
Initializes and returns a newly allocated Icon with the specified renderingType.
Parameters
Name | Type | Description |
---|---|---|
renderingType | DSIconRenderingType |
The renderingType to style the component. |
renderingSize | DSIconRenderingSize |
The renderingSize to style the component. |
Properties
renderingSize
public var renderingSize: DSIconRenderingSize = .size20
The width and height of the icon. Icons are always square.
renderingSizeString
@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.
renderingType
public var renderingType: DSIconRenderingType = .none
The image used by the icon. Can be changed after initialization.
renderingTypeString
@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.
intrinsicContentSize
public override var intrinsicContentSize: CGSize
Methods
prepareForInterfaceBuilder()
public override func prepareForInterfaceBuilder()