• 截取指定区域


    //frame 是你所需要的区域大小

    +(UIImage *)screenshotsImageFram:(CGRect)frame{

        UIWindow *screenWindow = [[UIApplication sharedApplication] keyWindow];

        UIGraphicsBeginImageContext(screenWindow.frame.size);//全屏截图,包括window

        [screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()];

        UIImage *viewImage =UIGraphicsGetImageFromCurrentImageContext();

        UIGraphicsEndImageContext();

        CGRect rect1 =frame;

        UIImage * image = [UIImage imageWithCGImage:CGImageCreateWithImageInRect([viewImage CGImage], rect1)];

        return image;

    }

  • 相关阅读:
    抽象工厂模式
    工厂方法模式
    单例模式
    适配器模式
    外观模式
    简单工厂模式
    设计模式开篇闲谈
    android ui更新
    android获取Context
    android 事件绑定
  • 原文地址:https://www.cnblogs.com/Lrx-lizi/p/7591822.html
Copyright © 2020-2023  润新知