zoukankan      html  css  js  c++  java
  • 将某视图View转换为UIImage

    + (UIImage *)getSharedScreenView{
        
        UIWindow *screenWindow = [[UIApplication sharedApplication]keyWindow];
        ScreenView *currentView = [[[self class] alloc] init];
        currentView.frame = screenWindow.bounds;
        [screenWindow addSubview:currentView];
    
    //UIGraphicsBeginImageContext() 图片会失真模糊    
        UIGraphicsBeginImageContextWithOptions(screenWindow.frame.size, NO, 0.0);//图片不模糊
        [screenWindow.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage* viewImage =UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        [currentView removeFromSuperview];
        //UIImageWriteToSavedPhotosAlbum(viewImage,nil,nil,nil); //写入到相册
        return viewImage;
    }
  • 相关阅读:
    C++ reference
    C++ const 限定符
    POJ 1222 EXTENDED LIGHTS OUT(高斯消元)
    poj 2185
    poj 2406
    poj 2752
    hdu 6171
    hdu 6127
    uva 3708
    hdu 6092
  • 原文地址:https://www.cnblogs.com/jiefangzhe/p/8274568.html
Copyright © 2011-2022 走看看