Layers and UIViews

Whenever you retrieve a view from LWKLoadingContext‘s view accessors, an instance of UIView or one of its subclasses will be returned. By default, the type of view is determined by the content setup within the Lightwell editor; either a UIView, UIImageView, UILabel, or LWKShapeLayer will be returned. To override the default behavior see LWKLoadingContext.loadViews(usingGenerator:).

By default, views will already be setup with positions, sizes, anchor points, alphas, transforms, children views, and an attached ambient animation if one was defined in the Lightwell editor. Since these are native elements – with the exception of LWKShapeView – you have full access to futher edit or customize the views further.

The hierarchy of layers in the Lightwell editor is preserved in the generated views. To add all of the layers from a document, initialize a LWKLoadingContext and interate through all of its root views adding them to the destination hierarchy:

import HullabaluStoryKit
...
// Initialize the context
let loadingContext = LWKLoadingContext(screenName: "my awesome screen")
...
// Add all of the root views
self.loadingContext?.views.forEach { self.view.addSubview($0) }
}
...

To only add a subset of views, use LWKLoadingContext.view(for:) to select the intended views and then add them to the destination hierarchy:

import HullabaluStoryKit
...
// Initialize the context
let loadingContext = LWKLoadingContext(screenName: "my awesome screen")
...
// Add all of the root views
if let generatedView = self.loadingContext?.view(for: "view name") {
    self.view.addSubview(generatedView)
}
...

The API is currently in beta and everything inside of these docs will be changing to improve the SDK. If there is a change you’d like to see or have any feedback, please email us at dev@lightwell.pro.

If you have any questions please get in touch with us via email or chat with us on lightwell.pro!

  • 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.

    See more

    Declaration

    Swift

    public struct LWKLayerInfo
  • A UIView wrapper for a CAShapeLayer.

    Exposes properties to customize the shape and its draw rules.

    See more

    Declaration

    Swift

    public class LWKShapeView : UIView