简体   繁体   English

iOS Interface Builder自定义样式?

[英]iOS Interface Builder Custom Styles?

Simple question. 简单的问题。 Does anyone know why Interface Builder doesn't allow for applying custom styles on UI elements? 有谁知道为什么Interface Builder不允许在UI元素上应用自定义样式? Why is it only possible to do this programmatically? 为什么只能以编程方式执行此操作?

I can see how this might be difficult for custom UIView subclasses but the default controls definitely only have a tiny subset of the style options available through IB, such as background color or changing font colors. 我可以看到自定义UIView子类可能有多难,但默认控件肯定只有IB提供的样式选项的一小部分,例如背景颜色或更改字体颜色。 Why is this the case? 为什么会这样? Is there any way to approach a concept like application themes through IB? 有没有办法通过IB接近应用主题这样的概念?

My personal feeling is that Apple does this right. 我个人的感觉是Apple做得对。 They provide the elements and styles that fit the HIG. 它们提供适合HIG的元素和样式。 If they start adding other elements/styles then where do the start, and where do they draw the line? 如果他们开始添加其他元素/样式,那么从哪里开始,他们在哪里画线?

Also, it isn't like Apple actively prevents using custom elements/styles, they just don't include it in the tool set. 此外,它不像Apple积极阻止使用自定义元素/样式,它们只是不包含在工具集中。

The last thing we need is a tool set full of bloat. 我们需要的最后一件事是充满膨胀的工具集。

You'd really have to ask Apple as to the why . 你真的要向Apple询问原因 I'd guess that it's some combination of promoting consistent use of standard interface elements and limited development resources. 这是促进标准界面元素的一致使用和有限的开发资源的一些组合。

You can, of course, build interfaces using your own custom subclasses of the standard interface elements in IB. 当然,您可以使用IB中标准接口元素的自定义子类来构建接口。 It's a little more work, since you have to change the type of each object you add from UIButton to MyGreenButton or whatever, but it's not difficult. 这是一个更多的工作,因为你必须改变从UIButton添加到MyGreenButton或其他任何对象的每个对象的类型,但这并不困难。

It's also not hard to imagine coming up with a controller-type class that could connect to all your controls and whatnot to customize their appearance in some consistent, theme-like manner. 也不难想象想出一个可以连接到所有控件的控制器类,以及以某种一致的,类似主题的方式自定义它们的外观。 Add an instance of that to each nib, connect all the controls, and let it do it's thing. 将一个实例添加到每个nib,连接所有控件,并让它做到这一点。 You wouldn't see the effect until you actually run the app, of course, but it sounds like you're talking about customizing colors and fonts rather than size. 当然,在实际运行应用程序之前,您不会看到效果,但听起来您正在谈论自定义颜色和字体而不是大小。

Unfortunately you are at the mercy of the Almighty Apple Deity..... Bow at their feet and give thanks that you have what they give you..... lol... 不幸的是,你受到了全能的Apple Deity的支配.....在他们脚下鞠躬并感谢你拥有他们给你的东西.....大笑......

Seriously tho. 说真的。 Apple puts in what apple wants and you can request additions, but the IB is fairly minimal in the way of features. Apple提出了苹果想要的东西,你可以要求增加,但IB在功能方面是相当小的。

I think this may be by design. 我认为这可能是设计上的。 Somehow an Elegant Simplicity ? 不知怎的,优雅的简约?

The ability to customize the controls is given to the programmer however I think they want the controls standardized. 程序员可以自定义控件,但我认为他们希望控件标准化。 I just dont know why they didnt give a little more variety in the controls that are available. 我只是不知道为什么他们没有在可用的控件中提供更多种类。 Like a few more button styles for the ios devices... 就像ios设备的更多按钮样式一样......

If you find out otherwise I would definitely be all ears. 如果你发现否则我肯定会全力以赴。

I think that apple should let you to customize more the controls, for games it takes too much time to make the custom control ( you can make it faster in android as you can configure it in xml) 我认为苹果应该让你自定义更多的控件,对于游戏来说,制作自定义控件需要花费太多时间(你可以在android中加快它,因为你可以在xml中配置它)

Btw PaintCode is another option to make your own style for components, it will generate the code but its more like interface builder Btw PaintCode是为组件创建自己的样式的另一个选项,它将生成代码,但更像是界面构建器

http://www.paintcodeapp.com/ http://www.paintcodeapp.com/

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

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