Rendering UIView with its children

前端 未结 2 1340
北恋
北恋 2020-12-08 15:33

I have a UIView that has an image and some buttons as its subviews. I\'d like to get a \"snapshot\" image of it using renderInContext, or other met

2条回答
  •  春和景丽
    2020-12-08 15:51

    Try something like this:

    UIGraphicsBeginImageContext(clefView.bounds.size);
    [clefView.layer renderInContext:UIGraphicsGetCurrentContext()];
    UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    

提交回复
热议问题