I am able to create a UIImage from a Core Animation layer using the following code:
- (UIImage*)contentsImage;
{
UIGraphicsBeginImageContext([self bounds].size);
[self renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}...
Hi,
I am trying to move some custom drawing code from a view into a CAShapeLayer, which then get added as a sublayer to the original view's CALayer. This also works well, but when rotating the device, the animation starts to stutter, e.g. you just see the frame in the original orientation and then the final orientation, with at most one...
Thanks to some help on StackOverflow, I am currently animating a path in CAShapeLayer to make a triangle that points from a moving sprite to another moving point on the screen.
Once the animation completes, the triangle disappears from the screen. I am using very short durations because this code is being fired every .1 of second for ea...
I'm using a CAShapeLayer with a path. Now I want it to throw a smooth shadow with about 10 units of thickness.
First: Yeah, I could create just 11 CAShapeLayer objects and each time increase the outline of the path by 1 unit with an different color and some more alpha on every iteration. But this way I blow up my memory footprint since ...
I have a custom view with a layerClass override like:
+ (Class) layerClass
{
return [CAShapeLayer class];
}
I want to be able to add a CGImage to the contents property like so:
- (void) animateView
{
UIImage *layerImage = ...;
CAShapeLayer *layer = (CAShapeLayer *)self.layer;
layer.contents = layerImage.CGImage;
...
I'm trying to draw a semi-transparent shape over an image.
I've got a UIView which has it's layer's contents set to the image, with a CAShapeLayer sub-layer who's path is set to the shape. There are a few of these UIViews inside a parent UIView, which is the zoom child of a UIScrollView.
Everything is fine on the iPhone, but when I zoo...