In my iOS app I am using SWRevealViewController to add menu functionality. It works great, however my client wants to make the menu cover the current view controller, not move it to the right.
I mean something like this:
before:
after:
The author of this library told me to implement the following, where I can get current offset of the menu and move the current view controller by that offset by doing something like that:
let rvrw = self.revealViewController().rearViewRevealWidth
var bounds = navigationController!.view.bounds
bounds.origin.x = rvrw
navigationController!.view.bounds = bounds
The problem is that the menu is behind it. I would like to know how I can do that in this library or if there is another library with similar implementation and that functionality as well.
I have found tons of libraries, but all of them are pushing the controller not covering it. I have found one or two which do it way I need, but they missed some features (like being under navigation bar), were outdated or buggy.
SWRevealViewController offers some customization options
documented in the SWRevealViewController.h header file.
It seems as though the frontView is the part with "WatchKit" in your example and the rearView is the menu.
In that case, you might be able to use setFrontViewPosition with the value FrontViewPositionLeftSide, which gives the frontView
// Left position, front view is presented left-offseted by rightViewRevealWidth
If that does not work, you could also try FrontViewPositionLeftSideMost, which gives the position
// Left most position, front view is presented left-offseted by rightViewRevealWidth+rigthViewRevealOverdraw
I did not have the setup at hand to try this.
Related
Built-in Photo application fades in/out navigationBar when you tap on an image . This way Photo app allows to see it full screen.
How does it do this (fade efect)?
As I understand navigationController?.navigationBar.alpha doesn't work anymore (so you can't animate it this way).
Sharing all my finding.
Complain mode on
Frankly, I feel half pissed/like a dummy that I had to fight a good day to implement simple thing existing in Apple app.
Complain mode off
First of all here is some context. I am working with navigationBar which are provided by navigationController (vs just standalone bars which are manually dropped in your view)
There are several approaches which I found. I will mention all of them (even if I had no success using them)
1) Animate change of alpha of navigationBar
UIView.animateWithDuration(0.1, animations: {
navigationController?.navigationBar.alpha = 0
}, completion: nil)
#rmaddy mention here that it works for him. However, I believe he has a standalone bar (vs a bar managed by navigationController).
I used a tool Reveal to check UI hierarchy and found couple of things.
- There is a navigationBar which is hidden (and navigationController?.navigationBar is referencing it). So you can change alpha to your hearts joy, but these changes won't be visible.
There is however another navigationBar . I assume it's referenced in some private members of navigationController (let's call it private navigationBar). It's visible and that's what is displayed at the top of your view.
2) Use setNavigationBarHidden:animated:
This is a standard way to hide/show navigation bar. It's animated different way (it slides/up and down). However, if it's ok for you, just go with this is, because it's simple and clean.
navigationController?.setNavigationBarHidden(true, animated: true)
Additionally you can wrap it in UIView.beginAnimations, UIView.commitAnimations to animate it together with some other stuff (to make it smoother)
3) Animate change of alpha of private navigation bar.
This worked for me:
let privateNavigationBar = self.superview?.superview?.superview?.superview?.superview?.superview?.subviews[1]
UIView.animateWithDuration(0.1, animations: {
privateNavigationBar.alpha = 0
}, completion: nil)
I am going way up through the hierarchy to get a view which contains private navigationBar (which is second subview for that view).
However, this approach has multiple downsides:
I believe # of superviews? depends on your app hierarchy (vs you are using split view and so on). I think you can generalize or may be you just walk the whole hierarchy to find non hidden UINavigationBar to solve this.
I have a feeling that Apple may frown at this (your app be not accepted to AppStore)
4) Make navigationBar transparent and set background image to be transparent and change alpha channel on it.
I can't find where I read about this idea. There was couple of mentioning.
There is Apple example app which shows how to customize NavigationBar, including making it transparent.
It's interesting that this example app works for me (the navigation bar is transparent in it). However, when I tried this code in my app it didn't work (I still didn't figured out what is going on with this). As usual there are bunch of variables (may be something in Info.plist, also they subclass NavigationController, also may be something in view hierarchy)
5) Adding standalone navigationBar
You can hide a bar provided by navigationController. Add your own to the UIView, wire it to #IBOutlet and use alpha animation on it (most likely that's what #rmaddy was referring too).
I checked and this is work.
This approach is used in this tutorial.
However, it has a downside:
I believe it won't handle well rotation, increase of statusbar height while call or GPS
Each time when I see a code like this (written in the article) I know that there will be problems with resizing: CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), 64.0)
You can potentially replace it with constrains. I went this route, but stumble upon some issues.
6) Other methods
I saw two more methods. I don't know whether they will work or what will be downsides:
One of them in this question: How to hide/show status bar and navigation bar by fading in/out at the same time like the Photos app in iOS 7?
And this answer: https://stackoverflow.com/a/18063898/422080
I want to create a fixed header that doesn't scroll with tableViewCells, or other content that I have. The header should stay in place fixed, just like in most iOS apps.
Here is the image of the issue I'm facing:
I tried embedding it in a NavigationController & a TabViewController. That didn't work.
I also tried adding a scroll-view.
I referred to this link but it's outdated and didn't help: how iphone facebook app make the navigation bar fixed
Thanks.
I'd really recommend fooling around with the Navigation controller until you figure it out, it's really the best method for this. If you've embedded it, I'd check out your view with the Attributes inspector, to make sure everything needed is enabled.
HOWEVER, there is another way I've used before. Create a new ViewController, and create two views inside of it. One will be your FakeNavBar, and the other will be a container/TableView that'll hold your data.
Once you've added both these to your new VC, just set them up normally, and bingo!
One tip for this, is that NavBar is typically 64 points high, so your fake bar will be something like this:
fakeNavBar.frame = CGRectMake(0, 0, theWidth, 64)
tableView.frame = CGRectMake(0, 64, theWidth, theHeight-64)
And your view hierarchy will look like this:
So I've been playing around with the examples included with ECSlidingView.
In the BasicMenu Example: I've placed 20 rows in the Settings table view. When I open the menu, the table view in settings continues to slide if I touch it.
In the TransitionFun Example, the table views are not slide-able when they're not full screen.
I've looked through the code and don't see what's causing this difference. Can someone point it out to me? I have an app that pretty much started as BasicMenu and I sometimes have trouble using the pan gesture to close the menu, because I end up accidentally sliding the mostly off screen table view instead.
Thanks!
Look at setting:
slidingController.topViewAnchoredGesture = ECSlidingViewControllerAnchoredGesturePanning | ECSlidingViewControllerAnchoredGestureTapping;
such that, when the top view is anchored, tapping and panning it will both result in sliding. This eliminates the ability to otherwise interact with the top view controller contents.
I remember seeing multiple apps that will have a little i on the bottom of the screen, and the corner will flap up a bit to show a few things, such as a masthead. The Maps app (before iOS6) has what I'm talking about in the bottom right corner. It shows allows you to print maps and drop the pin, etc.
I want to do exactly that. I want that corner to flap up, and show that I created it, and anything else. Is there any way I can create this? It can be text-based, image-based, anything. I tried something, but it didn't work:
I created the i (made a 'Round Rect Button' and turned it into an 'Info Light button), and tried making a new window in the .xib, and linking them together, but it didn't seem to work.
TL;DR: How do I create the info page that flaps up from the bottom right/left corner?
BTW: I'm using XIB, not storyboard.
That is fairly easy. You have to present your viewcontroller modally and set the transition mode:
controller.modalTransitionStyle = UIModalTransitionStylePartialCurl;
You can try to start a new project....select Utility Application....it will make a flip between the two viewcontrollers....just change the transistionStyle to what I wrote above then it should curl up like in the maps app
Note: Using Monotouch and doing all the UI Programatically.
Hello everybody,
I have a question.
I have this main UIViewController object, and I have 2 UIVIews inside it. This views will perform commands in some devices, etc. I'm planning to do some menu with a slider effect appearing from the left side as it's drawn below. In this menu the user will select some buttons, and this is gonna make to change the another two UIViews.
Here's my question:
I'm planning to use Modal View Controller as UIModalPresentationPageSheet, but how can It appear at the center of the screen horizontaly. I'd like to put it on the center on the left side. How can I change it?
If it's impossible, should I use the UIPopover?
Image Below
Thank you.
Lyniker
I don't think either will get you the animation effect you want. In general I would choose to slide in a view using UIView animation:
if(IsDrawerVisible == false) {
UIView.Animate(0.5, () => {
DrawerView.Frame = new RectangleF(
this.View.Bounds.Left + 300,
DrawerView.Frame.Y,
DrawerView.Frame.Width,
DrawerView.Frame.Height);
}, UIViewAnimationOptions.CurveEaseIn);
}
else {
// Move the frame of the DrawerView by subtracting from Frame.X
}
Of course you need a reference point (usually the parent UIView's left bounds) and do the appropriate calculations to move the "Drawer" component into view. This can be arbitrary though :-)
NOTE: If DrawerView is of type UIViewController / DialogViewController please use the new iOS 5 custom containment APIs or you'll get some seriously wonky behavior. See my blog post on child view controllers here:
http://blog.devnos.com/wont-somebody-please-think-of-the-children