0

Here is some simple code to draw a UIBezierPath:

UIBezierPath *path = [UIBezierPath bezierPath];
[path moveToPoint:CGPointMake(100.0, 100.0)];
[path addLineToPoint:CGPointMake(130.0, 130.0)];

CAShapeLayer *shapeLayer = [CAShapeLayer layer];
shapeLayer.path = [path CGPath];
shapeLayer.strokeColor = [[UIColor greenColor] CGColor];
shapeLayer.lineWidth = 3.0;
shapeLayer.fillColor = [[UIColor clearColor] CGColor];

[self.view.layer addSublayer:shapeLayer];

I am looking to be able to rotate & move this around while retaining its shape. Not sure what type of animations I can use, and UIView animations don't seem to be having an effect.

Any ideas? Thanks!

Kyle Begeman
  • 7,169
  • 9
  • 40
  • 58
  • 2
    You should post the code that you have and we can help you figure out why it isn't working. – Aaron Brager Aug 15 '14 at 22:02
  • Why use `UIBezierPath` if you haven't used them before on straight lines? Literally all you have to do is UIViews with `backgroundColor:[UIColor blackColor]` then you do a `UIView animateWithDuration:` to move their frames – LyricalPanda Aug 15 '14 at 22:07
  • @AaronBrager I have added some code and a better description of what I am ultimately looking to understand how to do. – Kyle Begeman Aug 15 '14 at 22:14
  • Looks good so far. Have a look at the `CABasicAnimation` class. [This will let you animate the stroke](http://stackoverflow.com/a/15651718/1445366). You can also [move it around](http://stackoverflow.com/a/8316443/1445366). – Aaron Brager Aug 15 '14 at 22:20
  • The path is visible at screen now? Can you post the code of the animations? Can you explain what kind of animations you are trying to achive? Can you post a screenshot/gif of the screen? – Luca Bartoletti Aug 15 '14 at 22:20
  • @KyleBegeman - did you google this? Quite a few promising looking answers... like this: http://stackoverflow.com/questions/15318918/how-to-make-my-uibezierpath-animated-with-cashapelayer – danh Aug 15 '14 at 22:22

0 Answers0