UITableViewCell的自定义selectedBackgroundView带有圆角

时间:2013-04-17 15:04:37

标签: ios uitableview custom-view

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

enter image description here
代码: 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

0 个答案:

没有答案