DarkAdapter: iOS 暗黑模式(Dark Mode) 适配库,纯Swift库

DarkAdapter

https://github.com/ZuopanYao/DarkAdapter

https://gitee.com/harvey520/dark-mode.git

iOS 暗黑模式(Dark Mode) 适配库

DarkAdapter to make adjust dark mode on iOS.

Requirements / 使用条件

  • iOS 11.0+
  • Xcode 12.0+
  • Swift 5.0+

Installation / 安装

CocoaPods

pod 'DarkAdapter'

Manually / 手动安装

If you prefer not to use either of the aforementioned dependency managers, you can integrate DarkAdapter into your project manually.

如果您不喜欢以上管理依赖库的方式,则可以手动将 DarkAdapter 集成到项目中。

Usage / 使用

The general adjust dark mode

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        let isDark = UITraitCollection.current.userInterfaceStyle == .dark
        if isDark {
            view.backgroundColor = .red
        } else {
            view.backgroundColor = .blue
        }
    }
}

Make use of DarkAdapter

AppDelegate

import DarkAdapter

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        /// Register 注册
        DAAdapter.register()
        
        return true
    }

Usage

import DarkAdapter

class ViewController: UIViewController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.da.backgroundColor = (.blue, .red)
        // OR
        // view.da.backgroundColor = (light: .blue, dark: .red)
    }
}

Support Attribute

UIView
backgroundColor
shadowColor
borderColor
tintColor
alpha
shadowOpacity

Additional

UIButton
image
backgroundImage
title
titleColor
UIImageView
image
highlightedImage
UILabel
textColor
UITextView
textColor
UITextField
textColor

License / 许可证

DarkAdapter is released under the MIT license. See LICENSE for details.

DarkAdapter 是在 MIT 许可下发布的,有关详情请查看该许可证。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Harvey66

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值