【问题标题】:Snap functionality in iOSiOS 中的快照功能
【发布时间】:2012-10-31 06:44:29
【问题描述】:

我有一个包含 3 个子视图的父 UIView,这里我有一个 UIButton 来捕捉整个视图。我已经使用

UIGraphicsBeginImageContext(CGSizeMake(320,480));
CGContextRef context = UIGraphicsGetCurrentContext();

UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); 

[self.view.layer renderInContext:context];

在这里我只需要捕获名称为 subview1 的第一个子视图。我该怎么做?

【问题讨论】:

    标签: objective-c


    【解决方案1】:

    CaptureSubView 像这样:

    UIGraphicsBeginImageContext(subview1.size);
    [subview1.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *screenShot = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext(); 
    

    【讨论】:

      猜你喜欢
      • 2012-12-14
      • 1970-01-01
      • 2021-08-10
      • 2019-05-31
      • 2020-11-08
      • 1970-01-01
      • 1970-01-01
      • 2023-03-20
      • 1970-01-01
      相关资源
      最近更新 更多