Flip UIView with thickness (like iBooks) - objective-c

I'm making a reversi clone, and trying to add some thickness when I flip the buttons (Like iBook transition view).
Right now, I use this code to flip the buttons on the board:
[UIView transitionFromView:whiteView toView:blackView duration:0.5f options:UIViewAnimationOptionTransitionFlipFromRight
completion:^(BOOL finished){}];
I found a project on github that have implemented this, but I can't get it to work with a child view added to the main viewController.
How do you add the transition to just flip a view, and not transition to a new viewController?
Thanks in advance
https://github.com/epatel/EPGLTransitionView

Related

How to make blur effect when view controller slides out

I've got a program with slide out menu. There's Menu button(BarButtonItem) in the right position. When the view controller loads I'm doing next
_menuBarButton.target = self.revealViewController;
_menuBarButton.action = #selector(revealToggle:);
So, when I click on the this button the View Controller slides out to right and I see another View Controller.
So, I want to make the main view controller blur when it slides out. I've got a code how to do it blur, but I can't implement this code because when I tap on the bat button it runs revealToggle: selector.
I've tried:
1. To set action for bar button. And firstly blur view controller:
- (IBAction)menuBarButtonTapped:(UIBarButtonItem *)sender {
[self setBlurEffect];
_menuBarButton.target = self.revealViewController;
_menuBarButton.action = #selector(revealToggle:);
[self.menuBarButton.target performSelector:#selector(revealToggle:)];
}
But app crashes with "unrecognized selector" (the solutions of this problem doesn
t help too).
I've wanted to use willDisapear method but it doesn't run, because the main view controller doesn't disapear. It just slides out.
So, could you help me with this problem?
P.S. I'll be happy if you propose any other effects for main view controller except blur.
P.P.S. Sorry for many mistakes in question.
I've found a good answer for me. I don't use several ViewControllers to implement menu panel.
Now I'm using another UIView calls menuPanel. It contains tableView(UITableView) and blurView(UIView). The second one is under first one.
You can blur this view in to ways:
From the code using next method.
(void) setBlurEffect {// Add blur view
CGRect boundsView = self.someView.bounds;
UIVisualEffectView *tableViewVisualEffect = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleExtraLight]];
self.tableViewVisualEffect.frame = boundsView;
self.tableViewVisualEffect.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
self.tableViewVisualEffect.backgroundColor = [UIColor clearColor];
[UIView transitionWithView:self.view
duration:0.3
options:UIViewAnimationOptionTransitionCrossDissolve
animations: ^ {
[self.someView addSubview:self.tableViewVisualEffect];
}
completion: nil ];
// Here you can add visual effects to any UIView control.
// Replace custom view with navigation bar in above code to add effects to custom view.
}
Where someView is view you want to do blur(or any other effect)
From the story board with Visual Effect View.(I've chosen)
After all I've set tableView and blurView into menuPanelView as pinned to all sides of the menuPanel with 0 distance.
And the last thing I've done I'm changing the position of the menuPanelView with animation:
[self.menuPanelView setFrame:self.visibleTableViewFramePosition];
[UIView animateWithDuration:0.8
animations:^{
[self.menuPanelView setFrame:self.invisibleTableViewFramePosition];
} completion:nil];
Where invisibleTableViewFramePosition is CGRect variable contains position of the menuPanelView when it has to be invisible. You also need to create visibleTableViewFramePosition.
That's all. Hope it may be helpful for someone=)

Fade UIView and Switch UIView

This is how I switch from one UIView to another UIView: self.view = MyView;
How would I fade out a view to my MySecondView?
You can use UIView's build in transition code to cross dissolve between them.
[UIView transitionFromView:self.view toView:MySecondView duration:0.25 options:UIViewAnimationOptionTransitionCrossDissolve completion:^(BOOL finished) {
// What to do when its finished.
}];
You can also use the regular animation options with something like this. I haven't tested this code as I'm not in front of Xcode but I use it all the time for labels and things without default animations.
[UIView animateWithDuration:0.25 animations:^{
[self.view setAlpha:0.0];
self.view = mySecondView;
[self.view setAlpha:1.0];
}];
Please note that it's not a good idea to do things like self.view = MyView to change screens. By the time you get to a few screens, your viewController will be filled with spaghetti code. You should consider presenting new view controllers that manage their views. One way you can do fade is as follows:
Fade the current view to black (with animation)
In the view controller that you are going to push use viewWillAppear to fade the view to black as well
Push/Present the view controller without animations.
Now use the viewDidAppear method of the newly presented view controller to fade in the view (with animation).

I would like to implement a half UITableView half MapView UIView with a button in the middle

Well, this is what I want to do in my app: I would like to implment a UIView with a map on the top half of the screen and a tableview on the other half with two buttons in the middle. If I press one of the buttons the map will get fullscreen and if I press the other one the tableView will fit all the screen.
Any suggestion?
In one view controller like a UINavigationController create an MKMapView with a frame the size of the top half of the view and add it as subview of your view controller. Then I would create a UIToolbar to hold your buttons and make the top of it's frame line up with bottom of the MKMapView. Finally create a UITableView with it's frame just below the others (make sure you hook up it's delegates).
Then assign the target of your UIBarButtonItem that makes the map go fullscreen to a method that animates the frames of all three views like this:
[UIView animateWithDuration:0.24
delay:0.0
options:UIViewAnimationCurveEaseOut
animations:(void (^)(void)) ^{
self.toolbar.frame = CGRectMake(0, MAP_HEIGHT_FULLSCREEN, 320, TOOLBAR_HEIGHT);
self.mapView.frame = CGRectMake(0,0,320,MAP_HEIGHT_FULLSCREEN);
self.tableView.frame = CGRectMake(0, MAP_HEIGHT_FULLSCREEN+TOOLBAR_HEIGHT, 320, MAP_HEIGHT_FULLSCREEN-MAP_HEIGHT);
}
completion:^ (BOOL finished){}
];
Create both views how you are planning, On one button click, change the frame of one view to fit the full screen, if you click the other button, do the same thing to the other view.

How can I implement a pointer arrow on a toolbar in iOS?

I'm looking to implement a pointer arrow above the currently selected toolbar icon much like the design found in Reeder and Instacast:
The pointer arrow should move across smoothly when another toolbar item is pressed. I need to be able to choose which items cause the arrow to move, as featured in Instacast and Reeder, where only certain items change the arrow position.
Can I do this without too much overhead and a lot of UIKit subclassing?
This shouldn't be too bad: just take an image of the little triangle like you have in your question, and put it in a UIImageView that sits above the toolbar.
Then set it up so that when the action: for the relevant toolbar button is called, the UIImageView slides so that it's in the right place, with animation. Something like:
[UIView beginAnimations:#"TriangleAnimation" context:NULL];
[UIView setAnimationDuration:0.25];
triangleImageView.frame = //new location here
[UIView commitAnimations];

UISplitViewController, animating views

I'm trying to animate my detail view controller to transition with a page curl (up/down). I'm trying to achieve a similar effect as the Notes application on the iPad, this transition was also reproduced by CulturedCode in their Things application for iPad.
My problem is that the animation is clipped to the bounds of the Detail View Controller, it doesn't animate into the Master View Controller, therefore limiting the effect. I see that Apple and CulturedCode managed to make this happen, but I'm stumped.
I've tried the following solutions:
self.splitViewController.view.clipToBounds = False;
self.view.clipToBounds = False;
self.tableView.clipToBounds = False;
The only other solution I can think of is discarding the UISplitViewController altogether and creating my own VC programmatically that will mimic the UISVC behavior so that both of the views (former separate view controllers) will share the same Super View.
Thank you in advance, any advice will help.
RR.
A solution it to just set clipsToBounds to NO and bring the details view to the front in it's superview. Like so:
detailsView.clipsToBounds = NO;
[detailsView.superview bringSubviewToFront:detailsView];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:detailsView cache:YES];
...
[UIView commitAnimations];
Where detailsView is your container for the details pane. This should do the trick and the details view will animate in front of the master view. I now have my page transition look quite like the Notes app.