zoukankan      html  css  js  c++  java
  • ios编程:iPhone Howto:给UIView拍照

    ios编程:iPhone How-to:给UIView拍照

    时间:2011-04-22 csdn博客 林家男孩
     

    基本原理就是主要将UIView的layer描绘到图形上下文。UIView全局拍照和局域拍照的代码如下:

    1 UIView全局拍照

    - (UIImage *) screenImage:(UIView *)view {
    UIImage *screenImage;
    UIGraphicsBeginImageContext(view.frame.size);
    [view.layer renderInContext:UIGraphicsGetCurrentContext()];
    screenImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return screenImage;
    }

    2 UIView局域拍照

    - (UIImage *) screenImage:(UIView *)view rect:(CGRect)rect {
    CGPoint pt = rect.origin;
    UIImage *screenImage;
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextConcatCTM(context,
    CGAffineTransformMakeTranslation(-(int)pt.x, -(int)pt.y));
    [view.layer renderInContext:context];
    screenImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return screenImage;
    }

    来源:http://blog.csdn.net/lbj05/archive/2011/04/02/6297209.aspx

  • 相关阅读:
    散列表(Hash Table)
    MVC中TextBox事件
    AJAX控制DropDownList两级联动
    唯一标示
    检查对象属性是否有空值
    foreach枚举div控制单个显示
    JS获取DropDownList其中一项的文本值
    随便
    MVC常用
    不可用输入框
  • 原文地址:https://www.cnblogs.com/iphone520/p/2471439.html
Copyright © 2011-2022 走看看