zoukankan      html  css  js  c++  java
  • scrollView截取指定区域的图片

    把scrollView放到一个容器里面,再截图就可以了

    scrollview放到容器:

        UIView *lunboCarrier = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.headerLevelView.frame) + widthWith6(24), Main_Screen_Width, widthWith6(170))];
        [self.headerV addSubview:lunboCarrier];
        lunboCarrier.backgroundColor = [UIColor clearColor];
        _lunboView = [[GXLunBoView alloc] initWithFrame:lunboCarrier.bounds]; // GXLunBoView是轮播图

    截图:

    +(UIImage*)imageFromView:(UIView *)theView atFrame:(CGRect)rect {
        
        UIGraphicsBeginImageContext(theView.frame.size);
        
        CGContextRef context = UIGraphicsGetCurrentContext();
        
        CGContextSaveGState(context);
        
        UIRectClip(rect);
        
        [theView.layer renderInContext:context];
        
        UIImage *theImage = UIGraphicsGetImageFromCurrentImageContext();
        
        UIGraphicsEndImageContext();
        
        return  theImage;
        
    }
  • 相关阅读:
    JAVA学习日报 8.26
    JAVA学习日报 8.25
    JAVA学习日报 8.24
    JAVA学习日报 8.23
    Docker 详解
    DRF 3 请求响应异常处理
    DRF 2 序列化器
    DRF 1 API接口规范
    计算机计算小数的方法
    软件结构体系第二章
  • 原文地址:https://www.cnblogs.com/tufei7/p/10431728.html
Copyright © 2011-2022 走看看