XCoderLiu's Blog

An iOS developer @ Tencent

吾生也有涯,而知也无涯!


我的 Github

Yosemites dark mode

检查Dark模式的代码如下:

NSDictionary *dict = [[NSUserDefaults standardUserDefaults] persistentDomainForName:NSGlobalDomain];
id style = [dict objectForKey:@"AppleInterfaceStyle"];
BOOL darkModeOn = ( style && [style isKindOfClass:[NSString class]] && NSOrderedSame == [style caseInsensitiveCompare:@"dark"]);

设置监听 darkmode 改变

[[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(darkModeChanged:) name:@"AppleInterfaceThemeChangedNotification" object:nil];

-(void)darkModeChanged:(NSNotification *)notif {
    NSLog(@"Dark mode changed");
}
最近的文章

Dart语法初窥

今天稍微体验了下 Dart 毕竟2020年了,Flutter 终于迎来了第一个 stable 版本。我学习 Flutter 还是喜欢从语言层面慢慢展开学习,贴一下 dart 官方学习网站。不在这儿详细讲每个语法细节,只讲我对比 swift c++ 或者 objective-c 的语法中看到的一些好玩的东西。MixinsMixins with official首先说说这个,它是我看介绍里面一眼没法看懂的东西。Look at this!// Mixins are a way of reusin...…

Flutter继续阅读
更早的文章

C++ 内存布局&虚函数

关于c++的内存布局比如我们写这样一个简单的代码class Parent{public: Parent(){} ~Parent(){} void Say() { cout << "Parent" << endl; }protected: private:};class Son:public Parent{public: Son() {} ~Son() {} void Say() { cout << "Son" << endl; }protec...…

C++继续阅读