【发布时间】:2012-07-17 12:11:22
【问题描述】:
我继承UIView,我覆盖-drawRect:,我用CGContext绘制图形。现在我想用UIImage 填充这个数字。知道怎么做吗?
编辑:
我的代码来自-drawRect:
CGContextBeginPath(ctx);
//here I draw my figure
CGContextClosePath(ctx);
CGContextClip(ctx);
//this doesn't work
UIImage * image = [UIImage imageNamed:@"blackbackground.jgp"];
[image drawInRect:rect];
//this neither
CGImageRef cgImage = image.CGImage;
CGContextDrawImage(ctx, rect, cgImage);
【问题讨论】:
-
我认为需要更多细节。当您说“填充”时,您是指像在绘画程序中那样填充,还是您的意思是您只想将图像绘制到上下文中,还是需要用您的图形遮盖您的图像?
-
我有一个圆形图形和一个矩形图像。首先,我需要拉伸图像以适合我的身材。其次,我想将角落成像为圆形,就像我的身材一样。你明白了吗,还是我不必要地复杂化了?
标签: objective-c ios xcode cgcontext