简体   繁体   English

如何在Xcode的“属性”检查器中添加节名称?

[英]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. 有什么方法可以在新添加的@IBDesignable属性中添加节名称,以提高可读性。

//
//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: 例如:

属性检查器中的示例属性

In the picture above, the view properties have the section name View . 在上图中,视图属性具有节名称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. 我已经知道自定义类的名称将在“属性”检查器中显示为节名称。

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. 但是,Xcode会自动对具有相似名称的可检查属性进行分组。 Those groups are separated with a line. 这些组用一条线隔开。 This behavior is also visible in your example picture: 此行为在示例图片中也可见:

自动创建的组之间的分隔符

By default your classname (A name of your custom class) becomes a title for IBDesignable properties 默认情况下,您的classname名(您的自定义类的名称)成为IBDesignable属性的标题

Here is reference documents, what you want. 这是您想要的参考文件。 IBInspectable / IBDesignable IBInspectable / IBDesignable

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM