elenionl / easydarkmode Goto Github PK
View Code? Open in Web Editor NEWThis is a tool for developers to easily adapt dark mode in iOS 13.
License: MIT License
This is a tool for developers to easily adapt dark mode in iOS 13.
License: MIT License
我在ios9测试机上设置了一个切换模式的按钮,但是发现并没有改变模式的颜色,所以是不是有监听的方法我自定义去改变
如果用户主动在APP内选择暗黑模式,但是系统却是亮色,支持吗?
UITraitCollection *lightCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight];
UITraitCollection *darkCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
UITraitCollection *unspecified = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleUnspecified];
UIImage *image = UIImage.new;
[image.imageAsset registerImage:light withTraitCollection:lightCollection];
[image.imageAsset registerImage:dark withTraitCollection:darkCollection];
UIImage *newImage = [[image.imageAsset imageWithTraitCollection:unspecified] copy];
[newImage.imageAsset registerImage:[image.imageAsset imageWithTraitCollection:lightCollection] withTraitCollection:lightCollection];
[newImage.imageAsset registerImage:[image.imageAsset imageWithTraitCollection:darkCollection] withTraitCollection:darkCollection];
这种方式会丢失UIImage对象的scale属性使获取图片的size出现问题,使用UITraitCollection对象前应该先与当前的[UITraitCollection currentTraitCollection]进行一次合并。
UITraitCollection *const scaleTraitCollection = [UITraitCollection currentTraitCollection];
UITraitCollection *const lightUnscaledTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight];
UITraitCollection *const darkUnscaledTraitCollection = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark];
UITraitCollection *const lightScaledTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[scaleTraitCollection, lightUnscaledTraitCollection]];
UITraitCollection *const darkScaledTraitCollection = [UITraitCollection traitCollectionWithTraitsFromCollections:@[scaleTraitCollection, darkUnscaledTraitCollection]];
reference:
programmatic-dynamic-images
Hi, would be nice to update to the latest Kingfisher, if possible
EasyDarkMode has
s.platform = :ios, "8.0"
but latests Kingfisher
s.ios.deployment_target = "10.0"
and connectWithKingfisher method will be needed to update.
Thanks :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.