zoukankan      html  css  js  c++  java
  • iOS

    • 此方法失真,模糊
    - (UIImage*) imageWithUIView:(UIView*) view{
        
        // 创建一个bitmap的context
        // 并把它设置成为当前正在使用的context
        UIGraphicsBeginImageContext(view.bounds.size);
        CGContextRef currnetContext = UIGraphicsGetCurrentContext();
        [view.layer renderInContext:currnetContext];
        // 从当前context中创建一个改变大小后的图片
        UIImage* image = UIGraphicsGetImageFromCurrentImageContext();
        // 使当前的context出堆栈
        UIGraphicsEndImageContext();
        return image;
    }
    
    • 完美解决失真模糊
    -(UIImage*)convertViewToImage:(UIView*)v{
        CGSize s = v.bounds.size;
        // 下面方法,第一个参数表示区域大小。第二个参数表示是否是非透明的。如果需要显示半透明效果,需要传NO,否则传YES。第三个参数就是屏幕密度了
        UIGraphicsBeginImageContextWithOptions(s, NO, [UIScreen mainScreen].scale);
        [v.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage*image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        return image;
    }
    
  • 相关阅读:
    awk例子
    vsftp搭建
    makefile里PHONY的相关介绍
    youget帮助使用手册
    正则表达式全集
    常用的正则表达式
    基本用法
    心情
    asp.net和java
    java and asp.net
  • 原文地址:https://www.cnblogs.com/adampei-bobo/p/6704214.html
Copyright © 2011-2022 走看看