简体   繁体   English

在Interface Builder中设置UIDatePicker背景颜色?

[英]Set UIDatePicker background color in Interface Builder?

When I set background color for UIDatePiceker in Interface Builder, nothing happens: the backgroundColor property is nil . 当我在Interface Builder中为UIDatePiceker设置background color ,没有任何反应: backgroundColor属性为nil But when I do it in code, it works fine. 但是当我在代码中执行它时,它工作正常。 What's happening? 发生了什么?

A work around I'm using is just creating a UIView behind it with a white background. 我正在使用的工作只是在它后面用白色背景创建一个UIView。 Adding the same constraints as the date view (I also added a height constraint which may be redundant for the UIDatePicker but I needed it for the view behind it). 添加与日期视图相同的约束(我还添加了一个高度约束,对于UIDatePicker可能是多余的,但我需要它用于它后面的视图)。

May be more work than you're looking for but it works for me instead of coding an outlet and setting the background on viewdidload. 可能比你正在寻找更多的工作,但它适用于我而不是编写插座并在viewdidload上设置背景。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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