私はこの階層を持つビューを持っています:
-UIView -UIImageView -UILabel
UIImageView には、サイズ変更可能/伸縮可能な画像を含む UIImage が含まれています。
スクリーンショットを撮ると、すべて問題ないように見えます。
http://i.stack.imgur.com/uA6Lg.png
しかし、ビューを UIImage にキャプチャしようとすると、結果は次のようになります。
http://i.stack.imgur.com/IzUyS.jpg
ご覧のとおり、引き伸ばされた画像の下部は変に見えます。
これは、ビューを UIImage にキャプチャするために使用するコードです。
- (UIImage *) imageWithView:(UIView *)view
{
[view setBackgroundColor:[UIColor whiteColor]];
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 2.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[view setBackgroundColor:[UIColor clearColor]];
return img;
}
注: アプリは @2x デバイスでのみ使用されます。