![](/img/trans.png)
[英]How to change the background color of a potion of a selected custom table view cell
[英]How can i change the background color of a table cell with multiple sections?
我有一個包含多個部分的表格視圖,當我觸摸該行時不知道如何更改背景顏色。
我找到了這個關於表格單元格的鏈接,但它只針對只有一個部分的表格:
cell.selectedBackgroundView = [[ UIView alloc] init];
[cell.selectedBackgroundView setBackgroundColor:[UIColor purpleColor]];
如果我使用此鏈接中的代碼,則被舍入的單元格(每個部分中的第一個和最后一個)將在手指上有一個看起來不太好的矩形。
我怎樣才能使這個矩形圍繞每個部分的第一行和最后一行的邊緣彎曲?
使用一些石英芯怎么樣。 您可以使用view.layer.cornerRadius = 5.0;
確保導入 header
#import <QuartzCore/QuartzCore.h>
編輯
然后嘗試創建自定義單元格並為背景視圖屬性設置 UIView 並根據需要更改顏色。 這樣它就會起作用。
更新
是的你是對的。 互聯網上有分組 tableView 的教程,讓我為您搜索它。 使用這篇文章它有你需要的一切http://pessoal.org/blog/2009/02/25/customizing-the-background-border-colors-of-a-uitableview/
這是另一個相同的stackoverflow帖子
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.