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;
    }
    
  • 相关阅读:
    黑客是如何知道我们常用的密码的
    一个核物理学霸为何两次收到BlackHat的邀请
    透过大数据剖析漫画何去何从
    SJF(最短作业优先)
    RR(轮转调度算法)
    hrrf(最高响应比)
    fcfs
    Process 2(完成版)
    进程2
    进程1
  • 原文地址:https://www.cnblogs.com/adampei-bobo/p/6704214.html
Copyright © 2011-2022 走看看