我设计了自定义TableViewCell,它具有自定义selectedBackgroundView +其他一些功能
的问题:
在TableView' Grouped'风格,第一&最后一个单元格在选择时应该有圆角。如何实现第一个和最后一个单元格的圆角。
代码: 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