但是,我想使用缩放功能来更改数据的水平范围,而不需要实际缩放。
到目前为止,我得到了这个密码:
(void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context {
/* retrieve the transformation matrix from the context. */
CGAffineTransform contextTrans = CGContextGetCTM(context);
/* Scale the context back, so all items will still have the same size */
CGContextScaleCTM(context, 1.0/contextTrans.a, 1.0/contextTrans.d);
<.. loop through all datapoints ..> {
/* Transpose the point-centers to the new zoomed context */
xCoord = xCoord * contextTrans.a;
yCoord = yCoord * contextTrans.d;
}
<.. drawing code ..>
}
这是可行的,但缺点是放大后元素会变得模糊。(每个屏幕像素仅呈现1/zoomfactor像素)
有什么方法可以防止这种模糊发生吗?
或者,是否有任何方法可以绘制到非转换的上下文,而不是转置的上下文?