如何在我自己的自定义选择器上获得在 UIPickerDate 默认视图上看到的灰色 color/translucency?
How do I get the grey color/translucency I see on UIPickerDate default view on my own custom Picker?
我创建了一个 UI 选择器,但默认情况下它只是透明的。我想 use/be 给定 RGB + 半透明度值,使选择器视图中常用的灰色。
它是与程序化 UI 日期选择器的默认颜色相同的灰色。谢谢!我需要它与 Apple 的人机界面指南保持一致。
添加了一张背景图片color/translucency我需要以下:
十六进制颜色 - #e8e9ed
RGB 颜色 - UIColor(红色:232/255,绿色:233/255,蓝色:237/255,alpha:1)
或者您可以使用#f7f7f7
希望有用。
iPhone SDK has two types of gray color both have opacity 1.
iOS 13 还引入了一系列六种不透明灰色,您可以在半透明效果不佳的极少数情况下使用这些颜色。
https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/
以及更改背景颜色。
浅灰色:
picker.backgroundColor = UIColor.lightGray
深灰色:
picker.backgroundColor = UIColor.darkGray
如果您希望选择器视图具有一定的透明度。你可以在上面添加渐变。
let view = UIView(frame: CGRect(x: 0, y: 0, width: picker.frame.width, height: picker.frame.height))
let gradient = CAGradientLayer()
gradient.frame = view.bounds
gradient.colors = [UIColor.white.cgColor, UIColor.lightGray.cgColor]
picker.layer.insertSublayer(gradient, at: 0)
找到带有渐变和浅灰色的图像。
picker view with gradient
我创建了一个 UI 选择器,但默认情况下它只是透明的。我想 use/be 给定 RGB + 半透明度值,使选择器视图中常用的灰色。
它是与程序化 UI 日期选择器的默认颜色相同的灰色。谢谢!我需要它与 Apple 的人机界面指南保持一致。
添加了一张背景图片color/translucency我需要以下:
十六进制颜色 - #e8e9ed
RGB 颜色 - UIColor(红色:232/255,绿色:233/255,蓝色:237/255,alpha:1)
或者您可以使用#f7f7f7
希望有用。
iPhone SDK has two types of gray color both have opacity 1.
iOS 13 还引入了一系列六种不透明灰色,您可以在半透明效果不佳的极少数情况下使用这些颜色。
https://developer.apple.com/design/human-interface-guidelines/ios/visual-design/color/
以及更改背景颜色。
浅灰色:
picker.backgroundColor = UIColor.lightGray
深灰色:
picker.backgroundColor = UIColor.darkGray
如果您希望选择器视图具有一定的透明度。你可以在上面添加渐变。
let view = UIView(frame: CGRect(x: 0, y: 0, width: picker.frame.width, height: picker.frame.height))
let gradient = CAGradientLayer()
gradient.frame = view.bounds
gradient.colors = [UIColor.white.cgColor, UIColor.lightGray.cgColor]
picker.layer.insertSublayer(gradient, at: 0)
找到带有渐变和浅灰色的图像。 picker view with gradient