I know that could be done, but I can't remember how.
I would like to create some properties of a view and been able to change this in interface builder. Also I would like that after I specify the class of the UIView that this view is rendered correctly in interface builder.
Can someone help me
Using a custom view in storyboardsOpen up your story board and drag a View (colored orange below for visibility) from the Object Library into your view controller. Set the view's custom class to your custom view's class. Create an outlet for the custom view in your view controller.
The UIView class is a concrete class that you can instantiate and use to display a fixed background color. You can also subclass it to draw more sophisticated content.
Storyboard Advantages over SwiftUIStoryboard consist of Xib and custom View which can be reusable in the projects. It is easier to build an app as there is only drag and drop of the elements of the storyboard. It consist of use number of developer who are used to Swift Storyboard.
Subclass your UIView as you usually would to extend the functionality. The two unique portions of code are @IBDesignable
which enables the live rendering in Interface Builder and @IBInspectable
which will surface the appropriate properties in Interface Builder.
@IBDesignable class NewView: UIView {
// Display New Color as an editable property in Interface Builder.
@IBInspectable var newColor: UIColor = UIColor.greenColor()
}
You can then do any required drawing by overriding the drawRect(rect: CGRect)
function using any newly provided properties.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With