UIUserInterfaceStyle style = UITraitCollection.currentTraitCollection.userInterfaceStyle;
根据模式设置颜色
UIColor *color = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) {
if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) {
return [UIColor yellowColor];
}
else {
return [UIColor redColor];
}
}];