2014-08-31 62 views

回答

0

我不明白你的問題。但是,如果你想更改單元格背景顏色和透明度,你必須設置阿爾法

cell.backgroundColor = [UIColor colorWithRed:0. green:0.39 blue:0.106 alpha:0.] 

電池接頭事件

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 

} 

如果要更改單元格顏色,當你點擊就可以使用這個方法。

0

使用此:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{ 
    UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath]; 

    cell.backgroundColor = [UIColor colorWithRed:x green:y blue:z alpha:alphaValue]; 
    //Or use: 
    cell.contentView.backgroundColor = [UIColor colorWithRed:x green:y blue:z alpha:alphaValue]; 
} 
1

使用本:

//change opacity when select row 
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
    cell.contentView.layer.opacity = 0.4; 
    return indexPath; 
} 

//the opacity back when deselect row 
- (NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; 
    cell.contentView.layer.opacity = 1; 
    return indexPath; 
} 
+0

思維來解釋您的解決方案几分? – 2015-04-20 17:13:14

相關問題