Skip to content

Instantly share code, notes, and snippets.

@C4Code
Created May 12, 2012
Embed
What would you like to do?
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