开发者

CGContextRef with UITableViewCell

I have a subclass of UIButton where it dynamically creates the highlight state background image with CGContex开发者_开发技巧tRef draw. When i place the button in a UIView, the highlight shows up fine. When i place the button inside a UITableViewCell the highlight doesn't show. I think it has something to do with CGContextRef because when I replace the CGContextRef outputted image with an image from the main bundle it works fine. Is there something special that needs to be done with CGContextRef when used in a UITableViewCell?

Here is my CGContextRef code inside the initWithFrame of my UIButton subclass:

    //HighlightImage
    //*************************
    UIGraphicsBeginImageContext(CGSizeMake(bRect.size.width, bRect.size.height));   

    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextSetRGBFillColor(context, 0, 1.0, 0, 1.0);
    CGMutablePathRef path = AKCGRoundedRectCreate(  CGRectOffset(bRect, 0, -bRect.origin.y), kCornerRadius);
    CGContextAddPath(context,path);
    CGPathRelease(path);

    CGContextFillPath(context);

    UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    [self setBackgroundImage: resultingImage forState:UIControlStateHighlighted];
    //[self setBackgroundImage:[UIImage imageNamed:@"mainBundleImage.jpg"] forState:UIControlStateHighlighted];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜