[英]Any way to get light image when iPhone is on dark mode?
> UITraitCollection *lightTrait = [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight];
image = [UIImage imageNamed:name inBundle:[NSBundle mainBundle] compatibleWithTraitCollection:lightTrait];
無論 iOS 設備的當前主題是什么,我都想在燈光 model 上獲得圖像。
但是上面的代碼似乎不起作用。
奇怪,我看不出你的代碼有什么問題。
您還可以嘗試以下方法:
let lightImage = image.imageAsset?.image(with: lightTrait)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.