So I have a custom nav bar in my iPad app which is a bit larger than the default 44 pixel bar (52 pixels tall). I want all the items in the nav bar to be center aligned which I have been able to do just fine with the exception of one item, the back button. I don't want to use a custom back button and instead just use the default one and just nudge its position down a bit so that its aligned with the center of my navbar. I haven't been able to find a clear answer to this and am not sure if its even possible. Anybody done something like this?
http://cl.ly/image/0g3f2M260B3C
UPDATE :
This can be done and I found the answer here : UIBarButtonItem Offset?
Ok well,but we can't change the custom back button position so try to implement that one also by custom.
By default back button position was center so we can't change that position.
Related
I have my swift 5 app working and I'm now adding a 'tool tips' feature, explaining what each part of the screen does.
The approach I have taken is from an article online - add a subview of grey to dim the background, then to that, add a subview of the item being described again, so it is now highlighted, then also, add a subview of an explainer bubble to explain the item highlighted.
This works fine, so long as the UIView I'm using isn't from a UIBarButtonItem. When it is, the bar buttons underneath the grey screen move around to accomodate what they believe is another bar button being added, which causes everything to miss-align. Other buttons do not have this problem, only UIBarButtons.
Any advice is greatly appreciated. Thanks.
Are you adding the duplicate subview to the bar itself? It'd probably be better to add it to the screen rather than the bar so it doesn't affect the bar's layout. In order to get its frame relative to the view controller so you can display your duplicate in the correct position, you could use:
barButtonItem.convert(barButtonItem.bounds, to: self.view)
Assuming self is a UIViewController.
I am developing a I-phone application.But there is a problem with setting the x position of the back bar button item .Please need help in this Regard.
you can customize navigation bar, then you can locate the back button.
if you use the default UI, just put a image or some text there. can not set x position.
In my App, I have a map view and I want to use a segmented control to change the map types (Standard, Hybrid, Satellite). The way I have the app set up, the status bar is hidden and it animates in, moving the navigation bar down a bit. To make sure it doesn't look awkward, I want to make it so the segmented control is attached to the navigation bar so it animates nicely as the status bar comes in. This is basically a picture of what I want to do:
So I noticed that the segmented control is inside a toolbar, so I contain mine in a toolbar as well. I've then tried adding the toolbar to the navigationBar as a subview. (self.navigationController.navigationBar). That works well accept that it can't be tapped because the navigation bar's frame doesn't enclose the extra space, so it can't receive touches. I tried making the frame of the bar bigger, and that worked, but the title and the buttons went away. Obviously there is some way to do this, and I would appreciate any help. Thanks.
I made a vertical (in looks) toolbar programmatically. Using initWithFrame I set the width and height of the toolbar and sent it to extreme right.
Now I added a bar button item to the toolbar and set an action for it. But when I click anywhere on the toolbar, the action message is being sent. And I checked the sender, the sender is not the toolbar but the button.
I tried on another toolbar which I placed horizontally, the buttons are seen as tapped if I click in the vicinity of the button. And since now my toolber is vertical (but horizontal according to iOS), clicking anywhere on the toolbar calls the function.
I want to send the message only when I click on the button and not on the toolbar.
I want to use the camera icon provided by apple, so I am not in favor of using UIButton. (I can set a custom image, but it would be good if i can avoid that)
I also think that placing a horizontal toolbar and using CGAffineTransform can solve the problem. But it would be nice if there is clean method.
Using the transform is definitely the way to go.
Run the identity transform through this function and set it as the transform on your bar. I think it is a very simple solution.
It shouldn't be hard to set the transform right after you init with a normal frame. To avoid stretching you can make that frame using the values you are already using but swapping the x and y.
I don't believe that UIToolbar supports vertical orientation; you'll probably be better off rolling your own toolbar-like control.
I have a requirement for a very simple Button Bar.
It should take up the width of the screen.
It should allow at least 3
buttons.
The buttons should be of equal width and together take up
the whole width of the bar.
Each button should be tappable, but not
have a selected state.
The bar will be overlaid on a MapView and positioned directly above a TabBar.
Tapping a button will launch a Modal ViewController.
I thought about using a UITabBar and not allowing its tabs to become selected, but the HIG is pretty clear that this is not correct usage and UIToolBar doesn't allow the button widths to be set.
This seems like a very simple requirement but I can't see an obvious solution. Is there something I'm missing? Can anyone suggest a solution?
What's wrong with just creating a simple view that draws an appropriate gradient, and then adding three buttons of the appropriate size?
If you're feeling ambitious, or if this is something that you're likely to use more than once, you could even have the view create the three buttons. Call it ThreeButtonBar or something. Give it a constant height and adjust the width to match that of its superview so that you can use it in portrait or landscape orientation.