本文介绍了配置@IBInspectable Attribute Inspector控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 是否可以配置在Attribute Inspector中显示和/或控制 @IBInspectable 属性的方式?例如,我有一个 CGFloat 属性覆盖Alpha,它在检查器中显示如下:Is it possible to configure how @IBInspectable properties are displayed and/or controlled in the Attribute Inspector? For example, I have a CGFloat property "Overlay Alpha" which shows up in the inspector like this: 问题是调节器向上/向下箭头仅以整数(+/- 1)步进更新。我希望它们以小步骤更新,比如+/- 0.05增量。有没有办法做到这一点?The problem is that the adjustor up/down arrows only update in integral (+/- 1) steps. I want them to update in small steps, say, +/- 0.05 increments. Is there any way to do that?控件的其他属性如何?你能为 CGFloat 而不是数字字段显示一个滑块吗?你能添加一个工具提示吗?你能添加静态描述性文字吗?How about other properties of the controls? Can you display a slider for a CGFloat instead of a numeric field? Can you add a tooltip? Can you add static descriptive text?只是想知道我可以自定义多少显示。我试图看看我能在多大程度上推动IBDesignable功能使IB成为一个真正的UI设计工具。Just wondering how much I can customize the display. I'm trying to see how far I can push the IBDesignable feature into making IB an actual UI design tool.推荐答案 问题是调节器上/下箭头仅以整数(+/- 1)步进更新。我希望它们以小步骤更新,比如+/- 0.05增量。有没有办法做到这一点? The problem is that the adjustor up/down arrows only update in integral (+/- 1) steps. I want them to update in small steps, say, +/- 0.05 increments. Is there any way to do that?缺少任何解释如何操作的文件以及你的问题是3年多的事实旧建议你实际上不能在IB中为你的可检查属性更改步进器的增量值。Lack of any documentation explaining how to do it and the fact that your question is 3+ years old suggest that you can't actually change the increment value of the stepper for your inspectable properties in IB.你可以做什么,但是,是根据您要调整的属性创建另一个属性,并缩放该属性,使增量1对应于您想要的大小的步数。例如,设计师可能习惯于根据百分比来考虑不透明度,因此您可以创建一个 alphaPercent 属性,其中包含扩展 alpha的getter和setter 属性增加100:What you can do, however, is to create another property based on the one you want to adjust, and scale that one so that increments of 1 correspond to steps of the size you want. For example, designers are probably used to thinking about opacity in terms of percentages, so you could create an alphaPercent property with getters and setters that scale the alpha property up by 100:@IBInspectable var alphaPercent : CGFloat { get { return self.alpha * 100 } set(percentage) { self.alpha = percentage / 100 }}如果您将该属性添加到 @IBDesignable 视图中,您将成为每次点击都可以使用步进器将视图的不透明度更改1%。If you add that property to an @IBDesignable view you'll be able to use the stepper to change the view's opacity by 1% with each click. 控件的其他属性如何?你能为CGFloat而不是数字字段显示一个滑块吗?你能添加一个工具提示吗?你能添加静态描述性文字吗? How about other properties of the controls? Can you display a slider for a CGFloat instead of a numeric field? Can you add a tooltip? Can you add static descriptive text?目前这些都不可能。如果您长期需要技术较少的用户来进行用户界面调整(例如,如果您为许多不同的客户设计相同的基本应用程序),那么构建一个提供的应用程序版本可能是有意义的。编辑模式。查看来自Facebook的Tweaks框架可能会给你一些想法。None of that is currently possible. If you have a long-term need for less technical users to make user interface adjustments (e.g. if you're skinning the same basic app for a number of different customers), it might make sense to build a version of your app that provides an edit mode. Looking at the Tweaks framework from Facebook might give you some ideas. 这篇关于配置@IBInspectable Attribute Inspector控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-15 18:02