Making Smartlook UIView Properties Inspectable in Xcode
This guide applies to all frameworks that use the Xcode Interface Builder.
Inspectable properties of visual elements used in the Xcode Design Builder enable quick codeless editing of their values.
Unfortunately, properties exported from an external framework like Smartlook cannot be directly attributed as IBInspectable
to enable this functionality.
There is, however, a neat straightforward workaround to enable this functionality by wrapping the Smartlook properties in its own inspectable properties via a custom UIView
extension:
extension UIView {
@IBInspectable var smartlookSensitive: Bool {
get { return slSensitive }
set { slSensitive = newValue }
}
}
By adding this code to your app, a wrapper is created around Smartlook's slSensitive
property that publishes its value to the Interface Builder as smartlookSensitive
. You can indeed use another name for the new inspectable property so it fits your code naming conventions.
Updated almost 3 years ago