I've got this in my CALayer drawing code
- (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;
}
}
Basically, its drawing pin stripes on top a view. I want it to fill the view.
The view is fixed at 40 high and the width of the iPad.
When i rotate, I tell the CALayer to redraw (which is another problem - i'd rather it just automatically scale to the new width).
Even with log outputs of the width and height above, it is correct. But when it draws in landscape - there is a ~100 pixel gap on the right...
Any ideas, or better way of doing this?
What a waste of my time.... I gave up and did it a different way.
Also.....Core Animation Programming Guide lied to me and told me CALayer had an autoResizingMask - which would probably solve this for me. It doesn't have this property, not on the iOS version of it anyway.... MacOS version probably has it.
I scrapped doing it in a CALayer and did the same thing in drawRect on a UIView and set the autoResizingMask of my UIView.
This solves it. Although somehow I feel like I should be doing it in a CALayer...?