怎样手机怎么取消夜间模式式

转自己的答案,针对网页版,并不完美。
安卓app为例,你可能没有发现,主页右上的点点点菜单下(非抽屉设置页面),有一选项,叫做“切换主题”,对,知乎的夜间模式就叫这个名儿。
安卓app为例,你可能没有发现,主页右上的点点点菜单下(非抽屉设置页面),有一选项,叫做“切换主题”,对,知乎的夜间模式就叫这个名儿。
已有帐号?
无法登录?
社交帐号登录
二次元普通居民,不入流程序员,http://0v0.link夜间模式的实现 - 推酷
夜间模式的实现
前天在做项目的时候, 遇到一个问题(夜间模式的实现),通常我们在设置夜间模式的时候,简单的做法是使用通知的设计模式,改变各个页面的背景色,然后设置一下透明的效果,可是一个真正的项目,并不能马虎,需要页面效果美观精致。本文参考了github上一个老外写的实现方案,
经过自己的理解整合,制作出了自己的页面模式的实现。
Xcode中floder 与 group 的区别
在这里我先要说明一下:在Xcode中蓝色和黄色文件夹的区别,因为本文就是使用到了蓝色的文件夹,通常蓝色文件夹在IOS中被称为folder,他在项目中只能被称为资源来使用,不能被编译代码。黄色文件夹被称为group一般在工程中是文件夹的形式,但是在本地目录里还是比较散乱的文件,为了更好地管理和规范一个工程的文件夹,请参考我的博文,一般先创建好工程的框架文件夹,然后拖入工程,选择复制和创建,这样再次新建的文件就会在对应的group文件夹中了。
实现的思路
将设置的夜间模式与日间模式的颜色RGB值分别写入plist文件,将日间模式定为系统的默认模式。需要创建三个plist文件。pliast A 用来存放模式(日间/夜间);pliast B 用来存放日间模式下的RGB颜色值,写入group中;plist C 用来存放夜间模式下的RGB的颜色值,写入floder中。其中 B 与 C 中相同的颜色值名字 key&对应的Value值(RGB 值)是不一样的,这样在检测到通知改变的时候,系统就根据当前的主题模式去根据路径寻找对应的plist A 或者 B文件,然后通过一个将RGB值转化为对应的颜色值的方法,进行改变页面的颜色,不仅能改变背景色,也可以通过这个方法改变一些控件的颜色值,这样就真正的实现了夜间模式,是不是有些麻烦呢?
图1.存放日间,夜间模式的路径
图2.日间模式的颜色值
图3.夜间模式的颜色值
下面我将会附上关键源代码。
//更主题的通知
#define ThemeChangeNotification @&ThemeChangeNotification&
//更改主题的通知
#define ThemeName @&ThemeName&
//主题名称
#import &UIKit/UIKit.h&
#import &Foundation/Foundation.h&
@interface ConfigurationTheme : NSObject
//主题配置信息
NSDictionary * _themesC
@property (copy, nonatomic) NSString *themeN
//当前使用的主题名称
@property (strong, nonatomic) NSDictionary *themesC //主题配置信息
@property (strong, nonatomic) NSDictionary *fontC
//字体的配置信息
//创建单例,确保该对象唯一
+ (ConfigurationTheme *)shareI
//获取当前主题下的图片名称
-(UIImage *)getThemeImageName:(NSString *)imageN
//获取当前主题下的颜色
- (UIColor *)getThemeColorWithName:(NSString *)colorN
View Code&ConfigurationTheme.h
#import &ConfigurationTheme.h&
@implementation ConfigurationTheme
//创建单例,确保该对象唯一
+ (ConfigurationTheme *)shareInstance{
static ConfigurationTheme *configuration =
static dispatch_once_t onceT
dispatch_once(&onceToken, ^{
configuration = [ConfigurationTheme new];
//重写init方法
-(id)init{
self = [super init];
if (self != nil) {
//读取主题配置文件
NSString *filePlist = [[NSBundle mainBundle] pathForResource:@&theme& ofType:@&plist&];
_themesConfig = [NSDictionary dictionaryWithContentsOfFile:filePlist];
//读取字体配置文件
NSString *fontConfigPlist = [[NSBundle mainBundle] pathForResource:@&fontColor& ofType:@&plist&];
_fontConfig = [NSDictionary dictionaryWithContentsOfFile:fontConfigPlist];
self.themeName = @&默认&;
//得到当前主题名称
- (void)setThemeName:(NSString *)themeName{
if (_themeName != themeName) {
_themeName = [themeName copy];
//获取主题配置的根目录
NSString * themePath = [self getThemePath];
NSString * filePath = [themePath stringByAppendingPathComponent:@&fontColor.plist&];
_fontConfig = [NSDictionary dictionaryWithContentsOfFile:filePath];
//获取当前主题配置的目录
- (NSString *)getThemePath{
//项目的根路径
NSString * resourcePath = [[NSBundle mainBundle] resourcePath];
if ([_themeName isEqualToString:@&默认&]) {
return resourceP
//获取当前主题的配置路径
NSString *configurationPath = [_themesConfig objectForKey:_themeName];
//主题的完整路径
NSString *themePath = [resourcePath stringByAppendingPathComponent:configurationPath];
return themeP
//获取当前主题下的图片
-(UIImage *)getThemeImageName:(NSString *)imageName{
if (imageName.length == 0) {
//获取当前主题配置的目录
NSString *configurationPath = [self getThemePath];
//图片名称在当前主题的文件路径
NSString *imagePath = [configurationPath stringByAppendingPathComponent:imageName];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
//获取当前主题下的颜色
- (UIColor *)getThemeColorWithName:(NSString *)colorName{
if (colorName.length == 0){
NSString *rgb = [self.fontConfig objectForKey:colorName];
NSArray *rgbs = [rgb componentsSeparatedByString:@&,&];
if (rgbs.count == 3)
float r = [rgbs[0] floatValue];
float g = [rgbs[1] floatValue];
float b = [rgbs[2] floatValue];
UIColor *color = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1];
+ (id)copyWithZone:(NSZone *)zone
View Code&ConfigurationTheme.m
#import &BaseNavigationController.h&
@interface BaseNavigationController ()
@implementation BaseNavigationController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
//监听主题切换的通知
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(themeNotification:) name:ThemeChangeNotification object:nil];
- (void)themeNotification:(NSNotification *)notification {
[self loadThemeImage];
- (void)loadThemeImage {
//使用颜色设置navigationBar的背景颜色
self.navigationBar.barTintColor = [[ConfigurationTheme shareInstance] getThemeColorWithName:@&blColor&];
//使用背景图片设置导航条
[self.navigationBar setBackgroundImage:[[ConfigurationTheme shareInstance] getThemeImageName:@&navigationbar_background.png&] forBarMetrics:UIBarMetricsDefault];
//设置导航栏字体颜色和大小
[self.navigationBar setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[[ConfigurationTheme shareInstance] getThemeColorWithName:@&ygColor&],NSForegroundColorAttributeName,[UIFont fontWithName:@&Helvetica& size:21.0],NSFontAttributeName,nil]];
- (void)viewDidLoad{
[super viewDidLoad];
[self loadThemeImage];
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
View Code&BaseNavigationController.m
日间模式和夜间模式:
已发表评论数()
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
正文不准确
标题不准确
排版有问题
主题不准确
没有分页内容
图片无法显示
视频无法显示
与原文不一致网易云音乐夜间模式怎么打开 网易云音乐夜间模式开启/关闭教程
网易云音乐网页版
<span id="num_a_人顶
<span id="num_b_人踩
网易云音乐夜间模式怎么打开?QQ下载吧为大家带啦网易云音乐夜间模式开启/关闭教程。
打开网易云音乐,点击左上角的标志,打开左侧菜单
打开左侧菜单后,选择&夜间模式&
打开夜间模式后,整个界面就进入夜间模式了
退出夜间模式,也就是把这个开关关上就好了
小伙伴们,久违啦!今天是第29期的【邪恶gif动态图】,海量福利等你来。“为什么会有潜规则?”“能躺着解决的事,为什么要去奋斗呢?”。。不多说,大家自己往下点吧,走过路过不要错过~网页设计教程与开发
提供各种常见网页效果
提供各种各样的设计教程
装扮QQ,让QQ变得更酷
设计参考,提高自升水平
学习服务器和操作系统
提供各种素材和工具
收藏学习资料
您现在的位置:&&>>&&>>&&>>&&>>&正文
提分怎么关闭自动开启夜间模式
  提分关闭自动开启夜间模式教程。在提分里面练习做题目的时候总是时间一到就会自动开启夜间模式?有时候灯光太暗不想开启夜间模式?可以关闭自动开启夜间模式,那么要怎么关闭自动开启夜间模式方法呢?现在小编就教大家提分关闭自动开启夜间模式方法。
  1)点击打开【提分】,点击右下角的【我的】;(如下图)
  2)点击下方的【设置】,然后点击【自动开启夜间模式】旁边的【按钮】即可。(如下图)
转载请注明:破洛洛(谢谢合作)
上一篇文章: 下一篇文章:
网友评论:}

我要回帖

更多关于 微博取消夜间模式 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信