saintjab saintjab - 11 months ago 67
iOS Question

Draw a plus (+) sign uisng CALayer

I am not good with CALayer but I need to draw a plus (+) sign and I don't want to use an image as I want to animate the drawing. Any help?


After all the down votes, I was able to do it myself. Here's how for others who might need this

CGFloat height = 2.f;
CGFloat width = 3.f;
CGFloat cornerRadius =  1.f;

CALayer *hLayer = [CALayer layer];//this is the left - right stroke 
hLayer.frame = CGRectMake(0, CGRectGetMidY(self.bounds)-(height/2), width, height);
hLayer.cornerRadius = cornerRadius;

CALayer *vLayer = [CALayer layer];// this is the top - bottom stroke
vLayer.frame = CGRectMake(CGRectGetMidX(self.bounds) - (height/2), -3,height, width);
vLayer.cornerRadius = cornerRadius;

[self.layer addSublayer:hLayer];
[self.layer addSublayer:vLayer];