如何自定义TI Swipeable uiTableViewCell的外观?

时间:2011-05-16 11:47:12

标签: iphone ios uitableview

根据例子建议我应该覆盖drawContentView 如果我想在单元格中添加一些UIView。你能告诉我一些例子吗?

- (void)drawContentView:(CGRect)rect {
    UIColor * textColour = [UIColor blackColor];

    if (self.selected) {
        textColour = [UIColor whiteColor];
        [[UIImage imageNamed:@"selectiongradient.png"] drawInRect:rect];
    }

    [textColour set];

    UIFont * textFont = [UIFont boldSystemFontOfSize:22];

    CGSize textSize = [text sizeWithFont:textFont constrainedToSize:rect.size];
    [text drawInRect:CGRectMake((rect.size.width / 2) - (textSize.width / 2), 
                                (rect.size.height / 2) - (textSize.height / 2),
                                textSize.width, textSize.height)
            withFont:textFont];
}

0 个答案:

没有答案