简体   繁体   中英

Swift change text color to dark/lightmode

I am trying to change the text color in a UITextView from light grey to white/black.

So the new text color should be white when the dark mode is on and the text color should be black when the light mode is on.

You can set the UIColor to.label

textView.textColor = .label

This should use the system label colour which is back against a white background and vice versa

You can also create your own dark/light colours in the assets file. 在此处输入图像描述

And then use them in code or the interface builder.

textView.textColor = UIColor.init(named: "myBlueColor")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM