Make UIButton accessible in Interface Builder

Multi tool use
Multi tool use


Make UIButton accessible in Interface Builder



I'm working on a little project which adds a little bar on the bottom of the screen, similar to UITabBar (see screenshot below). It's an @IBDesignable class. The blue boxes you can see are buttons with placeholder images. Now my question is, can I somehow open up these buttons to the IB as well? Like when I click one of the boxes I get the attribute inspector for that specific button?
Thanks in advance


UITabBar


@IBDesignable



enter image description here





Well, if every button has it's own xib, you can edit them there.
– Sulthan
Jul 1 at 11:02




1 Answer
1



Sorry I miss understood the question. No you can't have a UIButton as an attribute in the interface builder. I believe @IBInspectable only supports a certain group of types.



These are the types that I know, maybe there are more types.



However, you can do something like the example below and apply that to other properties:


@IBDesignable class CustomTabBar: UITabBar {
var button1: CustomButton!
var button2: CustomButton!
var button3: CustomButton!

@IBInspectable var button1Title: String? {
get {
return button1.titleLabel?.text
} set {
button1.setTitle(newValue, for: .normal)
}
}
}






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

7,RWN4,odPregMMNR5f0DfuMMp4qDqg sdaA sHCTq kP
TBSA0djzM,w,Wox3Z

Popular posts from this blog

Rothschild family

Cinema of Italy