LWKLayerInfo

public struct LWKLayerInfo

A struct containing all of the info to display static layer content.

All layers share display properties related to positioning, sizing, transforming, and transparency. Additionally, if an ambient animation was defined in the Lightwell editor, a CAAnimation will be stored in LWKLayerInfo.ambientAnimation.

The layer info will have a different LWKLayerInfo.LayerContent depending on the contents that were defined for the layer in the Lightwell editor.

  • The name of the layer, and the key for LWKLoadingContext.view(for:)

    Declaration

    Swift

    public var name: String?
  • The position relative to the default iOS origin (top left).

    Declaration

    Swift

    public var position: CGPoint
  • The size of the contents before transforms are applied.

    Declaration

    Swift

    public var size: CGSize
  • The anchor point defining what point in the layer the position corresponds to and where transforms will be applied around. Normalized between top left (0.0, 0.0), and bottom right (1.0, 1.0).

    Declaration

    Swift

    public var anchorPoint: CGPoint
  • The affine transform combining scale and rotation values.

    Declaration

    Swift

    public var transform: CGAffineTransform
  • The opacity of the layer.

    Declaration

    Swift

    public var alpha: CGFloat
  • A looping, autoreversing, additive animation.

    Declaration

    Swift

    public var ambientAnimation: CAAnimation?
  • Specifies the type of content, and contains all of the information needed to describe how to display it.

    Declaration

    Swift

    public var content: LWKLayerInfo.LayerContent
  • Specifies any shadow info for the view.

    Declaration

    Swift

    public var shadow: LWKLayerInfo.ShadowInfo?
  • List of all the layout contraints for the layer

    Declaration

    Swift

    public var constraints: [LWKLayerInfo.LayoutConstraint]
  • A convenience generator to convert the layer data into a UIView based on the values stored in content.

    If no view type is provided, the type of the view will be determined by the type of content.

    LWKLayerInfo.LayerContent.image(_:) and LWKLayerInfo.LayerContent.imageSequence(_:) will be converted to UIImageViews. Sprite animation details will be stored in the UIImageView properties: animationImages, animationDuration, animationRepeatCount

    LWKLayerInfo.LayerContent.text(_:) will be converted to a UILabel. The text properties will be assigned to textColor, textAlignment, and attributedText properties.

    LWKLayerInfo.LayerContent.box(_:) corresponds to a rectangle shape layer and will be converted to a UIView with the background color, border color, border width, and border radius set.

    LWKLayerInfo.LayerContent.shape(_:) corresponds all other primitive shapes and will be converted to an LWKShapeView which is a subclass of UIView that has replaced the traditional backing CALayer to a CAShapeLayer.

    LWKLayerInfo.LayerContent.vector(_:) corresponds to an svg asset and will be converted to a UIView with nested CAShapeLayer children defining each shape from the vector asset.

    LWKLayerInfo.LayerContent.unspecified will be initialized as a UIView positioned and sized as described with no contents.

    Declaration

    Swift

    public func toView(ofType viewType: UIView.Type? = nil) -> UIView

    Parameters

    viewType

    The type of view to initialize for the Lightwell layer. If nil, the default type will be used.

    Return Value

    A styled instance of UIView.

  • An enum defining all of the potential types of layer content exported from Lightwell.

    Each type has different associated information to describe the contents.

    • image: corresponds to a layer linked to a single png or jpg image. If the linked image cannot be found in the current project, the associated image will be nil.
    • imageSequence: corresponds to a layer linked to multiple images defining frame-by-frame animation. For more details on the associated content see ImageSequenceDetail.
    • box: corresponds to a rectange pimitive shape defined in Lightwell. For more details on the associated content see BoxDetail.
    • shape: corresponds to all other pimitive shapes defined in Lightwell. For more details on the associated content see ShapeDetail.
    • vector: corresponds to a layer linked to an svg asset. It will store an array of ShapeDetail defining all of the nested shapes.
    • text: corresponds to a text layer. It will store all of the font, color, and text infomation. For more details on the associated content see TextDetail.
    • scrollArea: corresponds to a scroll layer. It will store the background color and content size. For more details on the associated content see ScrollAreaDetail.
    • unspecified: corresponds to a layer without any contents and has no associated details.
    See more

    Declaration

    Swift

    public enum LayerContent
  • A struct storing all of the information describing frame-by-frame animatable content.

    See more

    Declaration

    Swift

    public struct ImageSequenceDetail
  • A struct storing all of the information describing text content.

    See more

    Declaration

    Swift

    public struct TextDetail
  • A struct storing all of the information describing rectangle shape content.

    See more

    Declaration

    Swift

    public struct BoxDetail
  • A struct storing all of the information describing shape content. This includes the primitive shapes and polygons from Lightwell and path information from svg assets.

    See more

    Declaration

    Swift

    public struct ShapeDetail
  • A struct storing all of the information describing a scrolling container.

    See more

    Declaration

    Swift

    public struct ScrollAreaDetail
  • A struct storing all of the information needed to describe gradient fills.

    See more

    Declaration

    Swift

    public struct GradientInfo
  • Shadow data is stored as a UIColor, blur radius, and offset.

    Declaration

    Swift

    public typealias ShadowInfo = (color: UIColor, radius: CGFloat, offset: CGSize)
  • Declaration

    Swift

    public struct LayoutConstraint