English 中文(简体)
如何改变选定的彩色故事片板固定细胞
原标题:How to change background selected color storyboard static cells

我有一张故事片。 在一场景中,我有一个静态电池内容的表。 是否可能将所选择的颜色从缺省选项(蓝色和灰色)中改成另一种颜色?

I know If I can change cell background color in forRowAtIndexPath but in this case I haven t any datasource function from tableview. I m sure that it is possible from IB or another function that I can modify...

提前感谢!

最佳回答

我有同样的问题。 解决办法有两个部分:

1) getting the cells, look at this. 2) changing the background color: you must create a UIView with the background color you need and set it as the selectedBackgroundView of the cell

例如,我在主讲控制器的眼光中使用了该守则:

UIView *backgroundSelectedCell = [[UIView alloc] init];
[backgroundSelectedCell setBackgroundColor:[UIColor colorWithRed:130/256.0 green:169/256.0 blue:171/256.0 alpha:1.0]];

for (int section = 0; section < [self.tableView numberOfSections]; section++)
    for (int row = 0; row < [self.tableView numberOfRowsInSection:section]; row++)
    {
        NSIndexPath* cellPath = [NSIndexPath indexPathForRow:row inSection:section];
        UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:cellPath];

        [cell setSelectedBackgroundView:backgroundSelectedCell];
    }  
问题回答

你们不需要书写一条单一的法典来实现这一点。 你们都可以使用故事片。 确实如此:

  1. Add a UIView to your UITableViewCell and link it to the selectedBackgroundView property of the cell (to find this property, you will need to drag the line from the "New Reference Outlet" and release it over the desired UITableViewCell)
  2. Change the color of the UIView to the desired color of the selected state

您可以做与<条码>背井离析财产相同的事情。 也可使用<代码>UIImageView,以使用图像,而不是使用IDView的单一肤色背景。

http://uxp.com.br/downloads/CustomCell.zip

在这里,我们那些在X-Code 5+...上使用自动停电的人们可以找到解决办法。

For the static cells, you can supposedly change the background color, but it won t work. Each individual cell, however, will automatically have a Content View inside it in IB. If we change the background of this Content View, it changes the cell background.

Just something to add to @Leandro Alves answer, so we don t have to drag extra UIViews onto our project!





相关问题
Plist Hierarchy and All Option

I have a string of data in a plist, which I ve got to display, hierarchically like this: Menu>Chapter>SubChapter>item>item details This might be super simple, in my initial menu, how would I have ...

Disable iPhone table rows

Is there any way to disable the "selectibility" of a UITableView row? Example: I would like to make an appointment for a haircut at a certain time with a certain stylist. What gets displayed to a ...

Nonintrusive visual cue for uitableviewcell

I d like to mark a tableview row in some way that shows it has been clicked by the user. I have a large number of rows and want users to know if they have already visited a particular row. This same ...

TableView oval button for Index/counts

Can someone help me create an index/count button for a UITableView, like this one? iTunes http://img.skitch.com/20091107-nwyci84114dxg76wshqwgtauwn.preview.jpg Is there an Apple example, or other ...

Unable to pushViewController for subview

I have a UINavigationController and I have seperate UIViews that I switch between using a UISegmentControl. On switching the views, I add the view as a subview to my navigation controller s view: [...

热门标签