I made a custom button and added an image using IB. In my code I use drawRect: to draw a line on the button's context.
The problem I have is the line is drawn behind the image.
I am trying to figure if there is something I should be doing to draw on top of the image (or on the image itself). Same thing happens if I just have a title on the button. The line is drawn behind.
Any ideas or functions to look at would be appreciated. Here is the code I use to draw a line.
Code:
The problem I have is the line is drawn behind the image.
I am trying to figure if there is something I should be doing to draw on top of the image (or on the image itself). Same thing happens if I just have a title on the button. The line is drawn behind.
Any ideas or functions to look at would be appreciated. Here is the code I use to draw a line.
Code:
Code:
@implementation UIButtonX // subclass of UIButton
-(void)drawRect:(CGRect)rect{
CGContextRef ctx=UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(ctx,[ UIColorredColor].CGColor);
CGContextBeginPath(ctx);
CGContextSetLineWidth(ctx, 3.0);
CGContextMoveToPoint(ctx,rect.origin.x, rect.origin.y);
CGContextAddLineToPoint(ctx, rect.size.width,rect.size.height);
CGContextDrawPath(ctx,kCGPathStroke);
}
@end