首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何制作基于主题的iPhone应用程序?

如何制作基于主题的iPhone应用程序?
EN

Stack Overflow用户
提问于 2011-11-05 19:48:58
回答 1查看 703关注 0票数 0

我想在我的iPhone应用程序项目中实现主题属性。我有大约5-6个背景颜色在第一级和1多个背景在第二级和第三级的图像,我想改变主题的变化。

我想从一个中心位置控制所有的颜色。

告诉我实现本教程或任何教程的最佳方式,或者任何示例代码。

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2011-11-05 20:58:19

我会创建一个类(最好是单例)来处理这个问题。

代码语言:javascript
运行
复制
@interface Themes {
    int    theme;   //or you can create a enum
}

-(UIColor *)colorForBackground;        //or any other component
-(UIImage *)backgroundImageForButton;  //..
-(NSString *)xibNameForController:(NSString *)controller;   //or you can add a enum/define for controllers

@property() int theme;   // used to change or get the current theme; You can also send a NSNotification when the theme is changed, so that the content is refreshed
@end

@implementation Themes
@synthesize theme;

-(UIColor *)colorForBackground{
    if(theme==0){
        return [UIColor whiteColor];
    }
    if(theme==1){
        return [UIColor blueColor];
    }
    //etc.
}
-(NSString *)xibNameForController:(NSString *)controller{
    if([controller isEqualToString:@"MailController"]){
        if(theme==0)
            return @"MainControllerTheme0";
        //...
    }
    //...
}
//..
@end
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8019972

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档