如何让iPhone应用程序“可换肤”?
一位客户要求我制作一个“可换肤”应用程序,但我真的不知道这意味着什么。 我疯狂地用谷歌搜索,但没有找到明确的答案或例子。
如果有人对此有任何线索,任何提示将不胜感激。
谢谢。
I was asked by a client to make a "skinnable" app and I don't really know what that means.
I googled like crazy and I didn't found a clear answer or an example.
If anyone has a clue about this, any tip would be appreciated.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
一般来说,这意味着应用程序将允许用户选择不同的 UI 外观,每个外观都有不同的配色方案、感觉等。
Generally this means the app will allow the user to choose different looks for the UI, each of which will have a different color scheme, feel, etc.
我实际上对我的项目做了什么。我决定使用多个故事板来更好地控制每个主题的整个 UI 和 UX。我通过将它们全部链接在一起的主故事板以编程方式将它们全部链接在一起。我就是这么做的,而且效果非常好。性能非常出色,同时仍然保持对每个主题的高水平细粒度控制。您甚至可以使各个视图控制器的标头和实现文件保持相同,就像在情节提要上保持名称相同一样。
举例来说,我正在开发的一个名为 Jam-mout(音乐播放器)的应用程序有多个高质量主题。 (附图片)。每个主题都有自己的故事板。
What I actually did with my project. I decided to use multiple storyboards to give me greater control over the entire UI and UX of each theme. I programmatically link them all together via a master storyboard that links them all together. That's what I did, and it works very very well. Performance is great, while still maintaining high level of fine grain control over each theme. You can even keep your Header and Implementation files the same for individual view controllers, just so as you keep the names the same on the storyboard.
So for instance, one of my apps that I'm working on called Jam-mout (A music player) has multiple high quality themes. (Image attached). Each theme has it's own storyboard.
对于 iPhone 应用程序,大部分 GUI 设计都是由操作系统提供的,您可以通过设置自定义导航栏背景图像、自定义按钮图形以及不同的字体/大小/粗细和空白来实现。确保您正在与熟悉 iPhone GUI 的设计师合作(如果您没有与设计师密切合作,这将是一场噩梦)。
我最近为一位想要高度定制 GUI 的客户制作了一个应用程序: http ://itunes.apple.com/us/app/gogoparis/id428497937?mt=8。一个“可换肤”应用程序将有多个这样的集合,因此用户可以在几种不同的整体样式之间进行选择。 (我希望你的客户有巨大的设计预算!)
For iPhone apps, where the majority of the GUI design is provided by the operating system, you could do it by setting custom Navigation bar background images, custom button graphics, and different fonts/sizes/weights and whitespace. Make sure you're working with a designer who's familiar with the iPhone GUI (if you're not working closely with a designer this is going to be a nightmare).
I recently put together an app for a client who wanted a heavily customised GUI: http://itunes.apple.com/us/app/gogoparis/id428497937?mt=8. A 'skinnable' app would have several sets like this, so the user could choose between several different overall styles. (I hope your client has an enormous design budget!)
我在这里的帖子应该可以帮助您开始:
推荐的 iOS 应用程序样式设计方法是什么?
如果您需要实时主题更改,此示例中的每个主题都可以在用户选择另一个主题(或皮肤)时发布通知 - 然后您可以更新主题实例本身。
或者,您可以为映射(NSCFDictionary)到中央主题工厂的主题创建标识符。与主题工厂一起使用的特定视图的示例标识符可以是字符串 MONImageSelectorTableCellThemeIdentifier。
一个处理所有主题加载并提供对主题的引用的示例管理器/工厂:
除此之外,在不了解您的要求的情况下很难更详细地回答您的问题。应用程序换肤的实现范围可以从非常简单到非常非常复杂。祝你好运。
my post here should help you get started:
What is the recommended method of styling an iOS app?
if you need live theme changes, each theme in this example could post notifications when the user selects another theme (or skin) - then you can update either the theme instance itself.
alternatively, you can create identifiers for themes which are mapped (NSCFDictionary) to a central theme factory. an example identifier for a specific view for use with the theme factory could be a string
MONImageSelectorTableCellThemeIdentifier
.an example manager/factory which handles all theme loading and vends references to themes:
beyond that, it's hard to answer your question in more detail without knowing your requirements. the implementation of skinning an app can range from very simple to very very complex. good luck.
这里已经有一些很好的答案,但我要补充一点,如果您使用 ui 工具包,例如 Three20
您可以使用 CSS 为所有内容设置皮肤,就像为网页设置皮肤一样。
Already some good answer here, but I'd add that if you use a ui toolkit such as Three20
you can skin everything using CSS as you might for web pages.
我确实意识到这是一篇旧帖子,但我想我应该在这个问题上分享我的一分钱:)
要使任何 Cocoa 应用程序可换肤,您需要考虑该应用程序的 3 个方面:
1) 一致性:我的意思是您希望所有窗口、视图(包括按钮、文本输入等)都有一个适用于整个应用程序的“标准”。这是你需要看的第一件事。虽然 iOS 和 OS X 等已经有了“主题”,即 Apple 的默认着色和布局方式,但您可以覆盖这些(请参阅单独的视图/窗口等...文档。2
)性能:使用皮肤等等......在编写自己的drawRect等......方法时,性能始终是一个问题。苹果为“默认”设置的代码已经过优化,因此您在执行此操作时需要密切关注应用程序的性能。很好的例子是:我应该使用带有渐变的图像,还是使用 NSGradient?两者在渲染时都存在性能问题,但问题是两者中哪个更好
3) userDefaults:这通常是您从中获取“皮肤设置”的区域。 userDefaults 基本上是您存储通常在首选项窗格中设置的所有信息的位置。
如果我是你,我会查看它的类参考:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/
此外,这是使用 userDefaults 的一个漂亮示例:
http://mobile.tutsplus.com/tutorials/ iphone/nsuserdefaults_iphone-sdk/
希望这有帮助!
I do realise this is an old post, but I thought I'd share my penny on the matter:)
To make any Cocoa app skinnable you need you think of 3 aspects of the app:
1) Uniformity: By this I mean that on all windows, views (including buttons, text inputs etc...) you want to have a 'standard' that will apply throughout the app. This is the first thing you need to look at. Although iOS and OS X alike already have 'themes' as to put it i.e. Apples default way of shading and laying things out, you can override these (refer to the individual view / window etc... documentation.
2) Performance: With skinning etc... performance is always an issue when it comes to writing your own drawRect etc... methods. The code apple have in place for the 'default' is already optimised, so you need to keep a close eye on the performance of the app whilst you are doing this. Good examples are: Do I use an image with a gradient, or do I use NSGradient? Both of which have performance issues when it comes to rendering them, but it's a question of which is the better of the two
3) userDefaults: This is generally the area where you'd be getting your 'skin settings' pulled from. userDefaults is basically where you store all of the information which you generally set in a preference pane.
If I were you I'd look into the class reference of it:
http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSUserDefaults_Class/
Furthermore, here's a nifty example of using userDefaults:
http://mobile.tutsplus.com/tutorials/iphone/nsuserdefaults_iphone-sdk/
Hope this helps!