【发布时间】:2014-03-18 19:34:39
【问题描述】:
我正在拍摄我的视图区域的快照并将其设置为新的 UIView。
UIView *currView = [self.view resizableSnapshotViewFromRect:mp.moviePlayer.view.frame afterScreenUpdates:YES withCapInsets:UIEdgeInsetsZero];
[currView setFrame:CGRectMake(0, 0, 204, 128)];
然后我尝试使用此设置 UIIamgeView 图像:
[image2 setImage:[self getUIImageFromThisUIView:currView]];
-(UIImage*)getUIImageFromThisUIView:(UIView*)aUIView
{
UIGraphicsBeginImageContext(aUIView.bounds.size);
[aUIView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return viewImage;
}
但它没有将 UIImageView 的图像设置为任何东西? 提前致谢
【问题讨论】:
-
这对于标准 UIKit 控件来说是正确的技术(尽管通常使用比例为 0 的
UIGraphicsBeginImageContextWithOptions来捕获视网膜分辨率图像),但对于MPMoviePlayerController,您应该使用thumbnailImageAtTime。见stackoverflow.com/questions/13855340/…
标签: ios uiview uiimage cgcontext