【发布时间】:2012-01-05 04:10:03
【问题描述】:
我的 CALayer 绘图代码中有这个
- (void) drawInContext:(CGContextRef)ctx {
self.frame = self.superlayer.bounds;
CGFloat height = self.bounds.size.height;
CGFloat width = self.bounds.size.width;
CGContextSetFillColorWithColor(ctx, [UIColor grayColor].CGColor);
//Draw a stripe every other pixel
int count = 0;
while (count < height) {
CGContextFillRect(ctx, CGRectMake(0, count, width, 1));
count=count+2;
}
}
基本上,它的绘图针条纹在视图顶部。我想让它填满视图。
视图固定在 40 高和 iPad 的宽度。
当我旋转时,我告诉 CALayer 重绘(这是另一个问题 - 我宁愿它自动缩放到新的宽度)。
即使是上面宽度和高度的日志输出,它也是正确的。但是当它在横向上绘制时 - 右侧有大约 100 像素的间隙......
有什么想法或更好的方法吗?
【问题讨论】:
-
有趣的是,如果我从纵向开始它很好,我旋转到横向并且很好,然后我再次旋转到纵向 - 它会改变!
标签: objective-c ios ipad calayer