{"rsdb":{"rid":"408070","subhead":"","postdate":"0","aid":"282065","fid":"99","uid":"1","topic":"1","content":"
\n

\u4e0d\u9002\u914d\u6df1\u8272\u6a21\u5f0f<\/strong><\/p> \n

\u76f4\u63a5\u5728info\u65b0\u52a0\u4e00\u4e2a\u5b57\u6bb5<\/p> \n

User Interface Style<\/code><\/p> \n

\u8bbe\u7f6e\u503c\u4e3a<\/p> \n

Light<\/code><\/p> \n

\u9002\u914d\u6df1\u8272\u6a21\u5f0f<\/strong><\/p> \n

\u9002\u914d\u6df1\u8272\u6a21\u5f0finfo\u91cc\u9762\u7684\u90a3\u4e2a\u5b57\u6bb5\u5c31\u4e0d\u7528\u6dfb\u52a0\u4e86<\/p> \n

\u4f46\u662f\u9700\u8981\u5728\u6bcf\u4e2aUIWindow,UIViewController,UIView<\/code>\u91cc\u9762\u589e\u52a0\u4e0b\u9762\u7684\u8fd9\u4e2a\u65b9\u6cd5<\/p> \n

-(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection<\/code><\/p> \n

\u5728\u8fd9\u4e2a\u65b9\u6cd5\u91cc\u53bb\u5224\u65ad\u548c\u66f4\u6539\u5f53\u524d\u754c\u9762\u6240\u6709\u5143\u7d20\u7684\u989c\u8272<\/p> \n

\u6211\u4e13\u95e8\u505a\u4e86\u4e00\u4e2a\u5355\u4f8b\uff0c\u628a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u6240\u6709\u989c\u8272\u90fd\u5355\u72ec\u4fdd\u5b58\u8d77\u6765<\/p> \n

\u8fd8\u6709\u4e24\u4e2a\u65b9\u6cd5\uff0c\u5206\u522b\u662f\u628a\u6240\u6709\u7684\u989c\u8272\u6539\u6210\u4e0e\u4e4b\u5bf9\u5e94\u6d45\u8272\u6216\u6df1\u8272<\/p> \n

\u5176\u5b9e\u5c31\u662f\u4e00\u4e2aColor,\u6d45\u8272\u662f\u4e00\u79cd\u8272\u503c\uff0c\u6df1\u8272\u662f\u53e6\u5916\u4e00\u79cd\u8272\u503c\uff0c\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u5b9a\u4e49\u591a\u4e2aColor<\/p> \n

\u5e94\u7528\u7a0b\u5e8f\u6240\u6709\u7684\u989c\u8272\u90fd\u4ece\u8fd9\u4e2a\u5355\u4f8b\u4e0a\u53d6<\/p> \n

\u5230\u65f6\u5019\u8c03\u4e00\u4e0b\u5355\u4f8b\u53ea\u9700\u8981\u628a\u754c\u9762\u5237\u65b0\u4e00\u4e0b\u5c31\u884c\u4e86<\/p> \n

-(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection\n{\n    [super traitCollectionDidChange: previousTraitCollection];\n    if (@available(iOS 13.0, *))\n    {\n        if(UITraitCollection.currentTraitCollection.userInterfaceStyle == UIUserInterfaceStyleDark)\n        {\n            [[Color darkColor] setDarkColorArray];\n            LRLog(@"\u6697\u9ed1\u6a21\u5f0f");\n        }\n        else\n        {\n            [[Color darkColor] setBrightColorArray];\n            LRLog(@"\u6b63\u5e38\u6a21\u5f0f");\n        }\n        UIWindow* window = [[[UIApplication sharedApplication] delegate] window];\n        [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[Color darkColor].dataColor2,NSFontAttributeName:[UIFont systemFontOfSize:18]}];\n        [self.navigationController.navigationBar setBackgroundImage:[UIImage imageWithColor:[Color darkColor].backColor] forBarMetrics:(UIBarMetricsDefault)];\n        [self.navigationController.navigationBar setShadowImage:[UIImage imageWithColor:[Color darkColor].backColor]];\n        [self.navigationController.navigationBar setBarTintColor:[Color darkColor].backColor];\n        window.backgroundColor=[Color darkColor].backColor;\n        self.view.backgroundColor=[Color darkColor].backColor;\n    }\n}\n<\/code><\/pre> \n 

Demo\u5730\u5740 https:\/\/github.com\/YouZhiZheShiJingCheng\/dark<\/a><\/p> \n<\/div>","orderid":"0","title":"iOS\u6df1\u8272\u6a21\u5f0f\u9002\u914d","smalltitle":"","mid":"0","fname":"iOS","special_id":"0","bak_id":"0","info":"0","hits":"63","pages":"1","comments":"0","posttime":"2020-03-26 06:13:25","list":"1585174405","username":"admin","author":"","copyfrom":"","copyfromurl":"","titlecolor":"","fonttype":"0","titleicon":"0","picurl":"https:\/\/www.cppentry.com\/upload_files\/","ispic":"0","yz":"1","yzer":"","yztime":"0","levels":"0","levelstime":"0","keywords":"iOS<\/A> \u6df1\u8272<\/A> \u6a21\u5f0f<\/A> \u9002\u914d<\/A>","jumpurl":"","iframeurl":"","style":"","template":"a:3:{s:4:\"head\";s:0:\"\";s:4:\"foot\";s:0:\"\";s:8:\"bencandy\";s:0:\"\";}","target":"0","ip":"14.17.22.34","lastfid":"0","money":"0","buyuser":"","passwd":"","allowdown":"","allowview":"","editer":"","edittime":"0","begintime":"0","endtime":"0","description":"iOS\u6df1\u8272\u6a21\u5f0f\u9002\u914d","lastview":"1590470418","digg_num":"0","digg_time":"0","forbidcomment":"0","ifvote":"0","heart":"","htmlname":"","city_id":"0"},"page":"1"}