AJRNight 1.0.0

AJRNight 1.0.0

测试已测试
Lang语言 Obj-CObjective C
许可证 Apache 2
发布最后发布2015年9月

Amar Ramachandran 维护。



AJRNight 1.0.0

  • Amar Ramachandran 编写

轻量级的 iOS 框架,用于将夜间模式添加到项目中


安装

  • 使用 Cocoapods,只需将以下内容添加到您的 podfile 中

pod 'AJRNight', :git => 'https://github.com/AmarJayR/AJRNight.git'

  • 手动安装

克隆项目,并将 AJRNight 目录中的文件添加到您的项目中


使用方法

AJRNight 非常轻量、灵活且易于使用。本质上,幕后的操作是我们在 UIView 中添加一个新的分类 nightProperties。这个字典包含所有需要更改的属性以便启用夜间模式(如 backgroundColortextColor 等。)

  1. 将以下行添加到任何需要夜间模式的视图控制器中

    #import <AJRNight/AJRNight.h>

  2. AJRNightDelegate 代理添加到您的视图控制器

    @interface PreferencesViewController : UIViewController <AJRNightDelegate>

  3. 在您的 viewDidLoad 中添加以下内容

    [[AJRNight sharedClient] addViewController:self];

  4. 编辑需要更改的任何 UIViewnightProperties。 -注意:通过 appearance[[UILabel appearance] setNightProperties:@{})设置夜间属性在大多数但不是所有 UIView 中受支持

    self.view.nightProperties = @{ @"backgroundColor": UIColorFromRGB(0x343338) };

    [[UILabel appearance] setNightProperties:@{ @"textColor": [UIColor whiteColor] }];

当您想要切换到夜间模式时,只需调用 [[AJRNight sharedClient] setNightMode:YES];

包含更多详细信息的示例项目已提供。