AIMRemoteConfiguration 0.4

AIMRemoteConfiguration 0.4

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最新发布2017年1月

Maciej Gad维护。



AIMRemoteConfiguration允许您在JSON文件中定义需要在应用程序中使用的颜色列表,并从互联网上获取它。它以异步方式工作。应用程序正常运行,在后台获取所有数据,然后在下一次启动时应用所有样式,因此用户在开始时看不到任何加载器。

用法

  • UIColor添加分类
#import "RemoteConfiguration.h"

@implementation UIColor (list)

+ (UIColor *)backgroundColor {
    return [RemoteConfiguration colorWithName:@"background"]?: [UIColor whiteColor];
}

+ (UIColor *)textColor {
    return [RemoteConfiguration colorWithName:@"text"]?: [UIColor blackColor];
}

@end
  • AppDelegate.m中进行设置
#import "AppDelegate.h"
#import "RemoteConfiguration.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [RemoteConfiguration setup];
    return YES;
}
 @end
  • 添加theme.json文件,包含您应用程序的默认配置
{
    "colors": {
        "background": "##d35400",
        "text": "#000000"
    }
}
  • 将配置添加到Info.plist

    • themeFileName - 默认配置的名称(无扩展名)(在我们示例中为theme
    • themeRemotePath - 远程配置的路径(在我们示例中为https://allinmobile.github.io/AIMRemoteConfiguration/remote_theme.json请记住HTTPS
  • 在应用程序中使用,例如:

#import "ViewController.h"
#import "UIColor+list.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *quotation;
@property (weak, nonatomic) IBOutlet UILabel *citation;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor backgroundColor];
    self.quotation.textColor = [UIColor textColor];
    self.citation.textColor = [UIColor textColor];
}


@end

安装

使用CocoaPods

将其添加到Podfile中

pod 'AIMRemoteConfiguration'

然后调用

pod install

然后导入

#import "RemoteConfiguration.h"

示例

Example文件夹中查看一个简单应用程序的示例,其中包含了集成AIMRemoteConfiguration

Check the full video