我使用itouch 4G和我的设备,我使用模拟器-4.2
我将只画一个矩形作为示例。我使用Quartz-2d绘图
- (void)drawRect:(CGRect)rect {
// Get a graphics context, saving its state
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
// Reset the transformation
CGAffineTransform t0 = CGContextGetCTM(context);
t0 = CGAffineTransformInvert(t0);
CGContextConcatCTM(context,t0);
// Draw a green rectangle
CGContextBeginPath(context);
CGContextSetRGBFillColor(context, 0,1,0,1);
CGContextAddRect(context, CGRectMake(0,0,320,480));
CGContextClosePath(context);
CGContextDrawPath(context,kCGPathFill);
CGContextRestoreGState(context);}
我在模拟器中运行它,整个屏幕变成绿色,然后在我的设备上运行,只有四分之一的屏幕变成绿色,为了在我的设备上使整个屏幕变成绿色,我必须绘制一个更大的矩形
CGContextAddRect(context, CGRectMake(0,0,640,960));好像我的设备的分辨率是模拟器的两倍,
我该如何解决这个问题呢?
发布于 2011-01-04 08:51:04
iPhone上的视网膜显示屏的分辨率是上一代手机的两倍。您的模拟器可能正在使用'iPhone‘设备而不是'iPhone4’设备运行。您可以在Hardware | Device菜单中切换。
您可以使用获取渲染到的当前视图比例
[self.layer contentsScale]然后相应地缩放您的尺寸。
https://stackoverflow.com/questions/4589706
复制相似问题