iOS Interface Builder 自定义样式?

发布于 2024-12-06 06:23:35 字数 189 浏览 1 评论 0原文

简单的问题。有谁知道为什么 Interface Builder 不允许在 UI 元素上应用自定义样式?为什么只能通过编程来完成此操作?

我可以看到这对于自定义 UIView 子类来说可能很困难,但默认控件肯定只有 IB 可用的样式选项的一小部分,例如背景颜色或更改字体颜色。为什么会这样呢?有什么方法可以通过 IB 来理解应用程序主题这样的概念吗?

Simple question. Does anyone know why Interface Builder doesn't allow for applying custom styles on UI elements? 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. Why is this the case? Is there any way to approach a concept like application themes through IB?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

泪是无色的血 2024-12-13 06:23:35

我个人的感觉是苹果在这方面做得对。他们提供适合 HIG 的元素和风格。如果他们开始添加其他元素/样式,那么从哪里开始,他们在哪里划清界限?

此外,苹果并不积极阻止使用自定义元素/样式,他们只是不将其包含在工具集中。

我们最不需要的就是一套臃肿的工具。

My personal feeling is that Apple does this right. They provide the elements and styles that fit the 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.

The last thing we need is a tool set full of bloat.

述情 2024-12-13 06:23:35

你真的必须询问苹果为什么。我猜想这是促进标准界面元素的一致使用和有限的开发资源的某种结合。

当然,您可以使用 IB 中标准界面元素的您自己的自定义子类来构建界面。这需要更多的工作,因为您必须将添加的每个对象的类型从 UIButton 更改为 MyGreenButton 或其他,但这并不困难。

也不难想象提出一个控制器类型的类,它可以连接到所有控件以及诸如此类的东西,以某种一致的、类似主题的方式自定义它们的外观。向每个笔尖添加一个实例,连接所有控件,然后让它做它的事情。当然,在实际运行应用程序之前您不会看到效果,但听起来您正在谈论自定义颜色和字体而不是大小。

You'd really have to ask Apple as to the why. 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. 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.

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. 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.

夜巴黎 2024-12-13 06:23:35

不幸的是,你受到了全能苹果神的摆布......在他们的脚下鞠躬并感谢你拥有他们给你的东西......哈哈......

说真的。 Apple 添加了 Apple 想要的内容,您可以请求添加内容,但 IB 的功能相当少。

我认为这可能是设计使然。不知何故优雅简单?

程序员可以自定义控件,但我认为他们希望控件标准化。我只是不知道为什么他们没有在可用的控件中提供更多的多样性。就像 ios 设备的更多按钮样式...

如果您发现其他情况,我肯定会洗耳恭听。

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...

Seriously tho. Apple puts in what apple wants and you can request additions, but the IB is fairly minimal in the way of features.

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...

If you find out otherwise I would definitely be all ears.

不语却知心 2024-12-13 06:23:35

我认为苹果应该让你自定义更多的控件,对于游戏来说,制作自定义控件需要太多时间(你可以在android中使其​​更快,因为你可以在xml中配置它)

顺便说一句PaintCode是另一种制作你自己的选项组件的样式,它将生成代码,但它更像是界面生成器

http://www.paintcodeapp.com/

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)

Btw PaintCode is another option to make your own style for components, it will generate the code but its more like interface builder

http://www.paintcodeapp.com/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文