iOS故事板:为原型单元格设置背景颜色 [英] iOS storyboard: set a background color to prototype cell
问题描述
我在使用XCode 4.5时遇到了一个非常奇怪的问题。
I am facing a very strange issue with XCode 4.5.
我试图在故事板中为原型单元格设置背景颜色,但在界面构建器中设置了单元格颜色不会改变,即使我在我的设备上运行它也不会使用我设置的颜色。
I tried to set a background color to a prototype cell in my storyboard, but in interface builder the cell color doesn't change, even when I run it on my device it doesn't use the color I set.
我尝试创建 UITableViewCell
并在所有init方法中设置背景颜色,但它仍然不起作用。
I tried creating a subclass of UITableViewCell
and setting the color of the background in all init methods but it still donnot work.
PS:XCode 4.5.1和iOS 5或6,同样的问题。由于我是新开发者,我不记得它是否适用于以前版本的XCode。
PS: XCode 4.5.1 and iOS 5 or 6, same issue. Since I'm a new developer I cannot recall if it worked on previous versions of XCode.
推荐答案
我能够添加一个Xcode 5中故事板内部原型UITableViewCell的背景颜色。
I was able to add a background color to a prototype UITableViewCell inside of a storyboard in Xcode 5.
首先,选择要提供背景颜色的单元格。
First, select the cell that you want to give a background color.
接下来,转到View - > Utilities - > Identity Inspector,为backgroundColor的键盘添加一个新的用户定义的运行时属性,一种颜色和一个你想要的任何颜色的值 。
Next, goto View -> Utilities -> Identity Inspector and add a new User Defined Runtime Attribute for a Keypath of "backgroundColor" a type of "Color" and a "Value" of whatever color you want.
这篇关于iOS故事板:为原型单元格设置背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!