Note that there are some explanatory texts on larger screens.

plurals
  1. POCAAnimation with a CGPath using arrays of values
    primarykey
    data
    text
    <p>I have a UIView with shapes drawn from a path, inside a loop using values from an array for radius and stroke width. The blends are important, as well as the switch colours (ignore the rgb macro). </p> <p>What I want to do is animate from the <code>oldShapeRadius</code> values to the <code>newShapeRadius</code> affecting the radius of the arc and <code>strokeWidth</code> of the <code>strokedArc</code>.</p> <p>Now I have looked at a lot of examples of Core Animation, but I can't see how it would affect the drawing of the effects as I have below, and how to work with CALayers? </p> <pre><code>//my UIView #import "QuartzCore/CALayer.h" #define degreesToRadians( degrees ) ( ( degrees ) / 180.0 * M_PI ) - (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.strokeWidth=38.0f; self.radius=47.0f; oldShapeRadius=[[NSMutableArray alloc] initWithObjects:[NSNumber numberWithFloat:1], [NSNumber numberWithFloat:1], [NSNumber numberWithFloat:1.0], [NSNumber numberWithFloat:1], nil]; newShapeRadius=[[NSMutableArray alloc] initWithObjects:[NSNumber numberWithFloat:0.6], [NSNumber numberWithFloat:0.9], [NSNumber numberWithFloat:1.0], [NSNumber numberWithFloat:0.5], nil]; } } - (void)drawRect:(CGRect)rect { for (int i=0; i&lt;4; i++) { UIColor *shapeColor; switch (i) { case 0: shapeColor=UIColorFromRGB(CATEGORY_COLOR_BLUE); break; case 1: shapeColor=UIColorFromRGB(CATEGORY_COLOR_GREEN); break; case 2: shapeColor=UIColorFromRGB(CATEGORY_COLOR_PINK); break; case 3: shapeColor=UIColorFromRGB(CATEGORY_COLOR_YELLOW); break; default: break; } CGMutablePathRef arc = CGPathCreateMutable(); CGPathAddArc(arc, NULL, 160.0f,85, radius*[[oldShapeRadius objectAtIndex:i] floatValue], degreesToRadians(90*i), degreesToRadians(90*(i+1)), NO); CGPathRef strokedArc =CGPathCreateCopyByStrokingPath(arc, NULL, strokeWidth*[[oldShapeRadius objectAtIndex:i] floatValue], kCGLineCapRound,kCGLineJoinRound,0.0f); context = UIGraphicsGetCurrentContext(); CGContextSetBlendMode(context, kCGBlendModeMultiply); CGContextAddPath(context, strokedArc); CGContextSetFillColorWithColor(context, shapeColor.CGColor); CGContextDrawPath(context, kCGPathFill); } } </code></pre> <p>Oh Lords of Stackoverflow may I have some help please. Is High Lord David Rönnqvist around haha. Many thanks in advance.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload