拆分UIImage一半? [英] Split UIImage in half?

查看:151
本文介绍了拆分UIImage一半?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

如何将UIImage拆分成两半(中间)您可以试试这个,

  UIImage * image = [UIImage imageNamed:@yourImage.png]; 
CGImageRef tmpImgRef = image.CGImage;
CGImageRef topImgRef = CGImageCreateWithImageInRect(tmpImgRef,CGRectMake(0,0,image.size.width,image.size.height / 2.0));
UIImage * topImage = [UIImage imageWithCGImage:topImgRef];
CGImageRelease(topImgRef);

CGImageRef bottomImgRef = CGImageCreateWithImageInRect(tmpImgRef,CGRectMake(0,image.size.height / 2.0,image.size.width,image.size.height / 2.0));
UIImage * bottomImage = [UIImage imageWithCGImage:bottomImgRef];
CGImageRelease(bottomImgRef);

希望这可以帮助你,:)


How would I go about splitting a UIImage In half(down the middle) so it would make two images?

解决方案

You can try this,

UIImage *image = [UIImage imageNamed:@"yourImage.png"];
CGImageRef tmpImgRef = image.CGImage;
CGImageRef topImgRef = CGImageCreateWithImageInRect(tmpImgRef, CGRectMake(0, 0, image.size.width, image.size.height / 2.0));
UIImage *topImage = [UIImage imageWithCGImage:topImgRef];
CGImageRelease(topImgRef);

CGImageRef bottomImgRef = CGImageCreateWithImageInRect(tmpImgRef, CGRectMake(0, image.size.height / 2.0,  image.size.width, image.size.height / 2.0));
UIImage *bottomImage = [UIImage imageWithCGImage:bottomImgRef];
CGImageRelease(bottomImgRef);

hope this can help you, :)

这篇关于拆分UIImage一半?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆