
我有一个加载的UIImage,我想:
1 – 在我加载的UIImage上绘制另一张图像
第二步 – 在我加载的UIImage上画一条线(有颜色和粗细)
如果你能想出一些基本的东西,我会非常感激,我还是一个菜鸟:)
解决方法 还有另一种选择,它使用核心图形.UIGraphicsBeginImageContextWithOptions(size,NO,0.0);CGContextRef context = UIGraphicsGetCurrentContext();CGContextSaveGState(context);UIImage *bottomImage = ...;CGRect bottomImageRect = ...;CGContextScaleCTM(context,1.0,-1.0);CGContextTranslateCTM(context,-bottomImageRect.size.height);CGContextDrawImage(context,bottomImageRect,bottomImage.CGImage);CGContextRestoreGState(context);CGContextSaveGState(context);UIImage *topImage = ...;CGRect topImageRect = ...;CGContextScaleCTM(context,-topImageRect.size.height);CGContextDrawImage(context,topImageRect,topImage.CGImage);CGContextRestoreGState(context);CGPoint origin = ...;CGPoint end = ...;CGContextMovetoPoint(context,origin.x,origin.y);CGContextAddlinetoPoint(context,end.x,end.y);CGContextSetstrokecolorWithcolor(context,[UIcolor whatever].CGcolor);CGContextstrokePath(context);UIImage *result = UIGraphicsGetimageFromCurrentimageContext();UIGraphicsEndImageContext();
编辑:稍微更改了代码,使图像不会反转
总结以上是内存溢出为你收集整理的在iOS中绘制加载的UIImage全部内容,希望文章能够帮你解决在iOS中绘制加载的UIImage所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)