這個問題很簡單,但很煩人。我在視圖控制器中放置了一個分組樣式的UITableView,並使控制器成爲表視圖的委託和數據源。自定義UITableView背景顏色
當我什麼改變表格的背景顏色,我用:
UIColor *backColor = [UIColor colorWithRed:(15.0/255.0) green:(170.0/255.0) blue:(230.0/255.0) alpha: 0.75f];
[self.myTable setBackgroundColor:backColor];
和tableView:tableView cellForRowAtIndexPath:indexPath
方法,我只返回一個簡單的細胞:
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:moreCellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
但奇怪事情是在每個單元格的圓角處顏色是不正確的,我認爲這是因爲單元格的其中一個子視圖的框架大於單元格,我試圖使子視圖的框架很小但仍然失敗任何想法?謝謝。
我認爲這是單元格寬度的問題,我將UITableViewCell分類並使寬度僅爲200的新單元類,但在表格視圖中單元格仍佔用幾乎整個屏幕寬度。 – joe522 2011-06-10 17:40:53