小编Con*_*ror的帖子

如何截取UIScrollView可视区域的截图?

如何获取UIScrollView可见区域的1:1屏幕截图?内容可能比UIScrollView边界更大或更小,也可能是半隐藏(我已经为较小的内容实现了自定义滚动,所以它不在左上角).我在模拟器上取得了预期的结果,但在设备本身上却没有:

-(UIImage *)imageFromCombinedContext:(UIView *)background {
      UIImage *image;
      CGRect vis = background.bounds;
      CGSize size = vis.size;
      UIGraphicsBeginImageContext(size);
      [background.layer affineTransform];
      [background.layer renderInontext:UIGraphicsGetCurrentContext()];
      image = UIGraphicsGetImageFromCurrentImageContext();
      UIGraphicsEndImageContext();
      CGImageRef imref = CGImageCreateWithImageInRect([image CGImage], vis);
      image = [UIImage imageWithCGImage:imref];
      CGImageRelease(imref);
      return image;
}
Run Code Online (Sandbox Code Playgroud)

uiscrollview ios

12
推荐指数
3
解决办法
6497
查看次数

如何在UIView之外使内容不可见

我有一个UIImageViewUIViewContentModeCenter,因此,它拥有图片没有得到缩放或变形.但是这样,如果图像更大,可以在ImageView的框架外看到它.我不想裁剪图像(用户可以缩放图像,因此数据丢失不是一种选择),但我需要将其中的一部分ImageView视为隐形或其他东西

uiimageview uiimage contentmode ios

4
推荐指数
1
解决办法
2018
查看次数

标签 统计

ios ×2

contentmode ×1

uiimage ×1

uiimageview ×1

uiscrollview ×1