簡體   English   中英

當 iPhone 處於黑暗模式時,有什么方法可以獲得明亮的圖像?

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM