我的设置包中有一个滑块,使用PSSliderSpecifier类型。我使用MinimumValueImage
和MaximumValueImage
键来提供显示在滑块左侧/右侧的图像。但是,如下面的屏幕截图所示,这些图像不会根据明暗模式进行调整。
如何在明/暗模式下指定要使用的不同图像或不同的色调?Apple 设置中的所有滑块似乎都会根据模式进行调整,所以感觉应该有办法,但我没有看到任何关于如何实现这一点的文档。
灯光模式
深色模式
我的设置包中有一个滑块,使用PSSliderSpecifier类型。我使用MinimumValueImage
和MaximumValueImage
键来提供显示在滑块左侧/右侧的图像。但是,如下面的屏幕截图所示,这些图像不会根据明暗模式进行调整。
如何在明/暗模式下指定要使用的不同图像或不同的色调?Apple 设置中的所有滑块似乎都会根据模式进行调整,所以感觉应该有办法,但我没有看到任何关于如何实现这一点的文档。
灯光模式
深色模式
出色地。首先你可以检测暗模式
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
if traitCollection.userInterfaceStyle == .light {
print("Light mode")
} else {
print("Dark mode")
}
}
您可以使用他的属性自定义滑块
slider.minimumTrackTintColor = .green
slider.maximumTrackTintColor = .red
slider.thumbTintColor = .black
以及当您检测到任何 userInterfaceStyle 时可以更改的音量图标