0
我有与该代码的自定义视图:iPhone - 图像绘制倒置放入一个CGGraphic上下文(自定义的UIView)
- (void)drawRect:(CGRect)rect
{
UIImage* theImage = [UIImage imageNamed:@"blue_arrow"];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextSetLineWidth(context, 1.0);
CGContextSetTextDrawingMode(context, kCGTextFill);
CGPoint posOnScreen = self.center;
CGContextDrawImage(context, CGRectMake(posOnScreen.x - theImage.size.width/2,
posOnScreen.y - theImage.size.height/2,
theImage.size.width,
theImage.size.height),
theImage .CGImage);
}
的图像是一个箭头,pointiing到顶部。
但是,当绘制时,它是上下颠倒,指向底部。
是什么导致了这个问题?
我该如何纠正,自然无副作用?
顺便说一句,应该没有理由保留然后释放从imageNamed获得的UIImage。 – picciano
是的,我知道,这是为了测试目的 – Oliver
看看[这个]问题(http://stackoverflow.com/questions/506622/cgcontextdrawimage-draws-image-upside-down-when-passed-uiimage-cgimage)的问题。 –