iamVishal16
iamVishal16

Reputation: 1780

How can I add section names in the Attributes inspector in Xcode?

Is there any way to add section name in newly added @IBDesignable properties for better readability.

//
//MARK: - Badge
//
@IBInspectable
var badgeColor:UIColor = UIColor.darkGray {
    didSet {
        updateView()
    }
}

@IBInspectable
var showBadgeOnIndex:Int = 0 {
    didSet {
        if showBadgeOnIndex >= buttons.count {
            showBadgeOnIndex = 0
        }
        updateView()
    }
}

@IBInspectable
var showAllBadge:Bool = false {
    didSet {
        updateView()
    }
}

@IBInspectable
var hideAllBadge:Bool = true {
    didSet {
        updateView()
    }
}

ex:

Example attributes in the Attributes inspector

In the picture above, the view properties have the section name View.

Any help would be appreciated.

I already know that the name of the custom class will appear as the section name in the Attributes Inspector.

Upvotes: 0

Views: 1565

Answers (2)

Krunal
Krunal

Reputation: 79656

By default your classname (A name of your custom class) becomes a title for IBDesignable properties

Here is reference documents, what you want. IBInspectable / IBDesignable

enter image description here

Upvotes: 0

glyvox
glyvox

Reputation: 58049

Sections and their titles in the Attributes inspector are generated based on what exact classes the properties in that section belong to. There is no way to change this behavior.

However, Xcode automatically groups the inspectable properties that have similar names. Those groups are separated with a line. This behavior is also visible in your example picture:

separator between automatically created groups

Upvotes: 1

Related Questions