自定义单元格选择中的问题iPhone中UITableView中的样式

Mon*_*mar 6 iphone objective-c uitableview

在我的应用程序中,我正在为TableView使用Grouped样式.在那我想要自定义单元格选择Style.I希望选择样式为红色.

我正在使用以下代码:

UIView *bgColorView = [[UIView alloc] init];
[bgColorView setBackgroundColor:[UIColor redColor];

[cell setSelectedBackgroundView:bgColorView];
[bgColorView release];
Run Code Online (Sandbox Code Playgroud)

通过使用上面的代码.我有一个问题.因为我已经采用分组样式表,在选择第一行和最后一行时,选择显示为带有尖边的矩形而不是呈现圆角.

任何人都可以帮助我.提前致谢.

Rah*_*air 3

尝试这个 ,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"CellIdentifier";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
        cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SelectedCellBackground.png"]] autorelease];
    }

    // Cell configuration takes place here
}
Run Code Online (Sandbox Code Playgroud)