I'm trying to rotate a line (which is nothing more than a UIView) around it's origin. For the rotation I'm using CGAffineTransformRotate
but I know this will rotate the line around it's center. To change the rotation point I'm using CGAffineTransformTranslate
. Despite this the line is not rotating correctly. What am I doing wrong? Here is my code:
- (void)viewDidLoad
{
[super viewDidLoad];
UIView *testView = [[UIView alloc] initWithFrame:CGRectMake(300, 400, 300, 3)];
testView.backgroundColor = [UIColor blueColor];
[self.view addSubview:testView];
testView.transform = CGAffineTransformTranslate(testView.transform, -150, 0);
testView.transform = CGAffineTransformRotate(testView.transform, 45 * M_PI / 180);
}
Thanks in advance