Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created May 12, 2012 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save C4Code/2667555 to your computer and use it in GitHub Desktop.
Save C4Code/2667555 to your computer and use it in GitHub Desktop.
how to rotate shapes using the shape.transform property (uses CGAffineTransform)
//
// C4WorkSpace.m
// rotate
//
// Created by Travis Kirton on 12-04-04.
// Copyright (c) 2012 POSTFL. All rights reserved.
//
#import "C4WorkSpace.h"
C4Shape *s1, *s2;
@implementation C4WorkSpace
-(void)setup {
s1 = [C4Shape rect:CGRectMake(200, 200, 100, 100)];
[self.canvas addShape:s1];
s2 = [C4Shape rect:CGRectMake(500, 200, 100, 100)];
s2.layer.anchorPoint = CGPointMake(0, 2);
[self.canvas addShape:s2];
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
s1.animationDuration = 1.0f;
s1.animationOptions = AUTOREVERSE | REPEAT;
s1.transform = CGAffineTransformMakeRotation(PI);
s2.animationDuration = 1.0f;
s2.animationOptions = AUTOREVERSE | REPEAT;
s2.transform = CGAffineTransformMakeRotation(PI);
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment