good guy
good guy

Reputation: 569

iPhone: can i save the screen or take screen shot to practicular area of view

On my screen there is an image and I have to save this image by taking a screenshot. Is there any other way of saving a particular area of the image only?

If there is a method, please guide me with a simple example.

Upvotes: 0

Views: 276

Answers (3)

kgutteridge
kgutteridge

Reputation: 8981

The following code will allow you to grab just a section of the screen, you could adapt for full screen

    CGRect screenRect = CGRectMake(0, 0, 200, 200);
UIGraphicsBeginImageContext(screenRect.size);

CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextFillRect(ctx, screenRect);

[self.view.layer renderInContext:ctx];

UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();

    //if you want to save this image to the photo album uncomment the next line
//UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);
UIGraphicsEndImageContext();

If you simply want to get a screenshot though just press the home and top button together which will put a screenshot in the photo album each time you do it

Upvotes: 1

Aletheia
Aletheia

Reputation: 87

If you need a programming way to achieve this you could use:

[[NSImage alloc] initWithData:[view dataWithPDFInsideRect:[view bounds]]];

Upvotes: 1

weltraumpirat
weltraumpirat

Reputation: 22604

Try pressing the home and close/power button at the same time.

Upvotes: 0

Related Questions