I'm maybe too complicated, but here is what I want:
@IBDesignable
class A: UIView {
@IBInspectable var title: String = "" {
didSet {
setNeedsLayout()
}
}
}
@IBDesignable
class B: UIView {
var firstView: A = A()
var secondView: A = A()
}
The B class have 2 @IBDesignable classes, so if I want to customize B directly in Interface Builder, I can't as I don't have access to the 2 A classes.
At first I create a protocol to list all elements in A class, but when a view need 2 or more item of A class, I can't use this.
Do someone have an idea to have only 1 B class in my storyboard and can customize both A classes?
Not very sure if your this is possible. This is not usually possible even when you use Apple Library classes, for example a UIButton has a UIView and also a UILabel.
Though these different classes and some things are possible by overriding as explained here
But I can provide you a hack here. In the object that you create for Object B in storyboard, you can add
User Defined Runtime Attributesas follows -firstView.title&secondView.titleI know this might not be the answer you are looking for, but thats just a way around.