So, I want to rotate my UIView in 3D. I did a quick search and the websites said: Use Core Animation. So, I took a look at this, and I came up with this code to make my image rotate.
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
animation.fromValue = @(0);
animation.toValue = @(4 * M_PI);
animation.repeatCount = INFINITY;
animation.duration = 5.0;
[self.layer addAnimation:animation forKey:@"rotation"];
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0 / -2000;
self.layer.transform = transform;
self.layer.masksToBounds = NO;
The actual view rotates fine, but it disables half of the view. Here's a quick picture I made in Photoshop to show what I mean
I have been looking for hours for hours, and I cannot understand what causes this. Any help or input would be appreciated. Thank.
EDIT: This is how I created the view:
UIView* test = [[UIView alloc] initWithFrame:CGRectMake(200, 200, 100, 100)];
test.backgroundColor = [UIColor redColor];
[self.view addSubview:test];
After you try it in the view created in the interface builder, it works fine, but I need to do it programmatically.