LoginSignup
0
0

Objective-cによるダークモード対応

Posted at

#Objective-cでダークモード対応をする

##記述の経緯
4年前に下書き保存されていたので供養
Objective-cの参考文献があまり無かった為

##コード

- (UIColor *)setElementLightStyleColor:(UIColor *)lColor darkStyleColor:(UIColor *)dColor {
    __block UIColor *showColor;
    if (@available(iOS 13.0, *)) {
        showColor = [UIColor colorWithDynamicProvider:^UIColor * (UITraitCollection * dynamicProvider) {
            if (dynamicProvider.userInterfaceStyle == UIUserInterfaceStyleDark) {
                return  dColor; //showColorにreturn
            } else {
                return lColor;
            }
        }];
    }else{
        return lColor;
    }
    return showColor;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0