views:

429

answers:

1

hello, i'm trying to draw a line from the originate point of an image view to its destination point. my problem is (i guess) how to set the superview as current drawing context (from the image view). can someone help please. this is the code i'm using in image view..

    //UIGraphicsPopContext();
CGContextRef context = UIGraphicsGetCurrentContext(); //(problem here????????)
CGContextSetLineWidth(context, 5.0); 
CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor); 

CGContextMoveToPoint(context, startLocationInView.x, startLocationInView.y); 
CGContextAddLineToPoint(context, destinationPositionInView.x, destinationPositionInView.y); 
CGContextStrokePath(context);
A: 

You cannot draw in other views. What you should do is expand your view's bounds to cover the whole area in which you want to draw.

Alternatively, you could add a new CALayer to your view's layer to cover areas that are outside of your view's bounds.

Nikolai Ruhe