【问题标题】:IOS Flaten a UIImageView in a UIVIew into a single UIView [duplicate]IOS将UIVIew中的UIImageView扁平化为单个UIView [重复]
【发布时间】:2016-09-23 18:12:49
【问题描述】:

我有一个 UIView,里面有另一个 UIView 和一个 UIImageView。我想将 UIImage 展平到 UIView 上。如果有帮助,您可以考虑这样的布局:
-UIView
---UIImageView
---UIView

如何捕获整个 UIView 并将其保存为单个图像?

【问题讨论】:

    标签: ios objective-c cocoa-touch


    【解决方案1】:

    您可以使用它来将您的视图保存为单个图像。

    -(UIImage *)visibleImage
    {
        UIGraphicsBeginImageContextWithOptions(yourview.frame.size, YES, [UIScreen mainScreen].scale);
        CGContextTranslateCTM(UIGraphicsGetCurrentContext(), CGRectGetMinX(yourview.frame) , CGRectGetMinY(yourview.frame));
    
        [yourview.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *img_FinalVisible  = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
    
        return img_FinalVisible;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多