Create a very easy-to-use "2.5D" view.
Here is a screenshot from the sample project:
This code is available under the MIT license.
- Drag files from the Classes folder to your project;
- #import "MC3DBoxView.h" wherever you want to use it.
Here's how you create MC3DBoxView and it add to your view hierarchy (example assumes that you do that from a view controller):
MC3DBoxView *boxView = [[MC3DBoxView alloc] initWithFrame:self.view.bounds
sideSize:self.view.frame.size
distance:-500];
[self.view addSubview:boxView];
sideSize is the size of the view which will be used as the sides of the box. By specifying this parameter, you can make box wider, taller and so on. distance is used to give a perception of depth when box is rotated. Usual values are somewhere between -500 and -2000.
Views for the four sides of the box are available as properties frontView, leftView, rightView, backView. Here's for example, how you would use an image to add texture to them:
UIColor *bg = [UIColor colorWithPatternImage:[UIImage imageNamed:@"checkers"]];
boxView.frontView.backgroundColor = bg;
boxView.rightView.backgroundColor = bg;
boxView.backView.backgroundColor = bg;
boxView.leftView.backgroundColor = bg;
And here's how you would add, say, a map to one of the sides:
MKMapView *mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
[boxView.frontView addSubview:mapView];