0
我必須做一些錯誤的,但我可以在下面用一些建議:Xcode中:試圖捕捉部分屏幕
我想捕捉的部分屏幕上的iPad都和iPad的視網膜。
我可以得到肖像視圖好,但我不能讓橫向視圖的右側進入界限。
這是我使用的(我沒有UIGetScreenImage之前這個問題()作出違禁品)的代碼..
CGRect screenRect = [[UIScreen mainScreen] bounds];
UIGraphicsBeginImageContext(screenRect.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
[[UIColor blackColor] set];
CGContextFillRect(ctx, screenRect);
[self.view.layer renderInContext:ctx];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
CGImageRef imageRef = CGImageCreateWithImageInRect([img CGImage], CGRectMake (0, 100, self.view.bounds.size.width, (self.view.bounds.size.height - 200)));
UIImage *img2Save = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
// Request to save the image to camera roll
UIImageWriteToSavedPhotosAlbum(img2Save, self, nil, nil);
這是兩個圖像,我得到的肖像和景觀:
謝謝。我用google和binging ..你有一個首選的方法來設置此。我能找到的最好方法是檢查方向,並手動設置座標。大衛 –
我發現這個SO後 - http://stackoverflow.com/questions/5677716/how-to-get-the-screen-width-and-height-in-ios,給了我一個更好的方便方法。但是你把我放在了正確的方向,我非常感謝。因此,我正在對此進行標記。再次感謝您。 –