I have a strange problem with a CALayer pattern for iPhone. I have a root layer that adds a bunch of sublayers representing "bubbles". The end result should look something like this:
http://www.expensivedna.com/IMG_0018.PNG http://www.expensivedna.com/IMG_0018.PNG
The problem is that I cannot make the layer smooth (note the jaggies on the bubbles). My drawInContext rewrite code for the CALayer bubble is as follows:
- (void)drawInContext:(CGContextRef)theContext{ CGContextSetAllowsAntialiasing(theContext, true); CGContextSetShouldAntialias(theContext, true); size_t num_locations = 2; CGFloat locations[2] = { 0.0, 1.0 }; CGFloat components[8] = { 1.0, 1.0, 1.0, 0.5,
}
Now itβs really strange that if I slightly changed the drawing code to draw regular red circles as follows:
- (void)drawInContext:(CGContextRef)theContext{ CGContextSetAllowsAntialiasing(theContext, true); CGContextSetShouldAntialias(theContext, true); CGContextSetFillColorWithColor(theContext, [UIColor redColor].CGColor); CGContextFillEllipseInRect(theContext, CGRectMake(0, 0, 40,40)); }
Everything looks like antialiases OK:
http://www.expensivedna.com/IMG_0017.PNG http://www.expensivedna.com/IMG_0017.PNG
I can't seem to understand this strange behavior. Is there any difference between smoothing gradients and normal circles?
Thanks guys.
source share