簡體   English   中英

突出顯示單元格時更改為自定義背景

[英]Change to custom background when a cell is highlighted

選擇自定義單元格后,如何更改其背景?

謝謝,尼爾斯

if (cell == nil) {

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    UIView *v = [[[UIView alloc] init] autorelease];
    v.backgroundColor = [UIColor blueColor];
    cell.selectedBackgroundView = v;

用這個

您需要UITableViewCell ,並重寫以下方法:

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;
- (void)setSelected:(BOOL)selected animated:(BOOL)animated;

您可以在那里更改單元格的背景圖像。

單元格的selectionStyle屬性也允許一些非常基本的自定義。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM