Skip to content

krystal1110/JYDarkModeKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JYDarkModeKit

CI Status Version License Platform

JYDarkModeKit主要功能:适配夜间模式,iOS10以上的系统均能适配,实时更新页面

Example

JYDarkModeKit is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'JYDarkModeKit'

使用教程

导入头文件

#import "JYDarkModeKit.h"

AppDelegate进行初始化工作

JYEnvironmentConfiguration * configuration = [JYEnvironmentConfiguration 
                                              initWithThemeChangeHandler:^{
        NSLog(@"themeChangeHandler");
    }];    
[JYTraitCollection setupEnvironmentWithConfiguration:configuration];
[JYTraitCollection registerWithApplication:application animated:YES];

设置背景颜色

self.view.backgroundColor = [UIColor jy_colorWithLightColor:[UIColor yellowColor] darkColor:[UIColor orangeColor]];

设置图片

UIImageView * imageView =  [[UIImageView alloc]initWithFrame:CGRectMake(50, 550, 100, 50)];
   
[imageView setImage:[UIImage jy_imageWithLightImage:[UIImage imageNamed:@"test3"] darkImage:[UIImage imageNamed:@"test"]]];

修改颜色

///普通模式
[JYTraitCollection setOverrideTraitCollectionStyle:JYInterfaceStyleLight animated:YES];
 
///夜间模式  
[JYTraitCollection setOverrideTraitCollectionStyle:JYInterfaceStyleDark animated:YES];

获取当前样式

///iOS13以上通过
[JYTraitCollection currentTraitCollection].uiTraitCollection.userInterfaceStyle 
  
///iOS13以下  
JYTraitCollection.overrideTraitCollection.userInterfaceStyle
  

Author

JY

License

JYDarkModeKit is available under the MIT license. See the LICENSE file for more info.

About

一个夜间模式适配框架

Resources

License

Stars

Watchers

Forks

Packages

No packages published