【发布时间】:2015-02-18 13:55:45
【问题描述】:
我有一些绘图代码尝试在 UIView 顶部绘制图层并显示图像。 for 循环代码在每次准备要显示的部分时调用 setNeedsDisplay 的更新,但视图上的 drawRect 仅在最后被调用。循环是否过快并中断了之前的调用?
for ( int i = 0; i < bitmapLength; i++ ) {
if ((tfx > 0) && (tfy > 0)) {
updateCount++;
sourceRect = CGRectMake(sx*8, ((((ipegHeight-1)/8)-sy)*8) + osy, tfx, tfy);
targetRect = CGRectMake(tx*8, ty*8, tfx, tfy);
ipegSection = CGImageCreateWithImageInRect(notJPEG, sourceRect);
// create a layer and draw section onto it
drawLayer = CGLayerCreateWithContext(ctxImage, targetRect.size, nil);
layerContext = CGLayerGetContext(drawLayer);
CGContextDrawImage(layerContext,targetRect,ipegSection);
// draw the layer onto the UIViews context
CGContextDrawLayerAtPoint(currentScreen, targetRect.origin, drawLayer);
CGImageRelease(ipegSection);
// Update the UI
[targetView setNeedsDisplay];
}
}
【问题讨论】:
标签: ios core-graphics