更改为深色模式的UIDatePicker选择的日期文本颜色(iOS 13) [英] Change UIDatePicker selected Date text Color for Dark mode (iOS 13)

查看:1531
本文介绍了更改为深色模式的UIDatePicker选择的日期文本颜色(iOS 13)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

难以找到在iOS 13暗模式下更改所选日期的文本颜色的解决方案.

Having trouble to find out a solution for changing the color of text for the selected Date in iOS 13 dark mode.

我知道如何使用代码更改UIPicker视图的文本颜色

I know how to change the color of the text of a UIPicker view using code

self.timePicker.setValue(UIColor.black, forKeyPath: "textColor")

或使用用户定义的运行时属性.但是,无法为iOS 13深色模式更改所选日期颜色.在背景为白色和黑色为文本的情况下,我的日期选择器视图如下所示:

OR using User Defined Runtime Attributes. But nothing is working for changing the selected date color for iOS 13 Dark mode. With background white color and black text color, my date picker-view looks like this:

因此,如果将文本颜色更改为黑色,则不会更改所选日期的文本颜色.它将所有其他文本颜色更改为黑色;但不是所选的.所选的一个保持白色,这是黑暗模式的默认设置.

So with changing the text color black, does not change the selected date text color. It changes all the other text color to black; but not the selected one. Selected one stays white, which is default for dark mode.

推荐答案

我找到了可以解决问题的方法.如果我将"hightlightsToday"颜色标记为false,则所选文本将以您设置代码的颜色显示.

I found something that solves the problem in a way. If I mark 'hightlightsToday' color to false, then the selected text shows with the color you set your code.

self.datePicker.setValue(false, forKey: "highlightsToday")

但是,如果我想用其他颜色突出显示我选择的日期文本颜色;在那种情况下,不确定我必须更改哪个键值.因此,如果有人知道如何更改暗模式下的选定日期文本颜色,我将保留这个问题.

But if I wanted to highlight my selected date text color with a different color; in that case not sure which key value I have to change. So I am going to leave the question open, incase anyone knows how to change the selected date text color for dark mode.

这篇关于更改为深色模式的UIDatePicker选择的日期文本颜色(iOS 13)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆