2

カスタム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
4

0 に答える 0