UIGraphicsBeginImageContext как установить позицию? - PullRequest
1 голос
/ 15 декабря 2011

Я делаю скриншот в моем приложении.Я могу сделать снимок экрана, но теперь я хочу сделать это, указав координаты x и y.Я имею в виду снимать скриншот с y = 40.Это возможно?

UIGraphicsBeginImageContext(screenshot.frame.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

1 Ответ

0 голосов
/ 15 декабря 2011
UIGraphicsBeginImageContext(screenshot.frame.size);
CGImageRef imageRef = CGImageCreateWithImageInRect((CGImageRef)self.view.layer.contents, cropRect);
UIImage *image = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
[image drawInRect:CGRectMake(...)];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
...