整体截图,设置起点大小截图

2019-06-04  本文已影响0人  疯子不爱看美剧

-(NSMutableArray*)fullScreenshots:(UIView*)view{

    UIGraphicsBeginImageContext(view.frame.size);//全屏截图,包括window

    [view.layer renderInContext:UIGraphicsGetCurrentContext()];

    UIImage *viewImage =UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    intViewHeight = view.frame.size.height;

    intnum =0;

    if(ViewHeight<=A4_Heigt) {

        num =1;

    }else{

        num = ViewHeight%A4_Heigt==0?ViewHeight/A4_Heigt:ViewHeight/A4_Heigt+1;

    }

    NSMutableArray *imgarry = [NSMutableArray new];

    for(inti =0; i

        floatoriginX =view.frame.origin.x;

        floatoriginy =view.frame.origin.y+A4_Heigt*i;

        floatwidth =A4_Widh;

        floatheight =A4_Heigt;

        //你需要的区域起点,宽,高;

        CGRectrect1 =CGRectMake(originX , originy , width , height);

        UIImage * imgeee = [UIImage imageWithCGImage:CGImageCreateWithImageInRect([viewImage CGImage], rect1)];

        [imgarryaddObject:imgeee];

    }

    returnimgarry;

}

上一篇 下一篇

猜你喜欢

热点阅读