我设计了具有自定义 selectedBackgroundView+ 一些其他功能的自定义 TableViewCell。
问题:
在 TableView 的“分组”样式中,第一个和最后一个单元格在选择时应该有圆角。如何实现第一个和最后一个单元格的圆角。
代码: MNATableViewCell 继承自 UITableViewCell
@implementation MNATableViewCell
-(void)drawRect:(CGRect)rect
{
[super drawRect:rect];
if(customSelectedBackgroundView==nil)
{
customSelectedBackgroundView = [MNATableViewCell getCellSelectedBackgroundView];
self.selectedBackgroundView = customSelectedBackgroundView;
}
}
+ (UIView*) getCellSelectedBackgroundView
{
UIView *bgView = [[UIView alloc] initWithFrame:CGRectZero];
UIImage *image = [UIImage imageNamed: @"bg-cell-active.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
[imageView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[imageView setFrame:bgView.frame];
[bgView addSubview:imageView];
[bgView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)];
[bgView sizeToFit];
return bgView;
}
@end