pimpampoum
pimpampoum

Reputation: 5984

Draw points in a view on iPhone screen?

in my class I have an attribute IBOutlet UIImageView *imageView; And if I want to draw an image in this view I do : imageView.image = [UIImage imageNamed:@"foo.png"];
But how can I do to draw some points with coordinate x, y (in pixel) directly in the view ?

Thanks !

Upvotes: 0

Views: 456

Answers (2)

Oldmicah
Oldmicah

Reputation: 170

After you follow Marcelo's suggestion to draw in the view, you can pull the uiimage from the view with something like:

+(UIImage *)grabImageFromView: (UIView *) viewToGrab {

UIGraphicsBeginImageContext(viewToGrab.bounds.size);

[[viewToGrab layer] renderInContext:UIGraphicsGetCurrentContext()]; 
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}

Upvotes: 0

Marcelo Cantos
Marcelo Cantos

Reputation: 185852

UIImageView isn't designed to allow arbitrary drawing code. For this purpose, use a UIView and override the drawRect: method.

Upvotes: 1

Related Questions