UIToolBar button not positioning correctly after increasing height - ios

Well the problem is well understood in the image below , so I'm trying to increase height of the UIToolBar but the buttons aren't aligning correctly to the toolbar. Is there any solution for it?

This is because the button will start their drawing from the top, so it will move lower once you start increasing the height of the button, since the text will be in the middle.
I am pretty sure there is no way to solve this.
EDIT:
I found a way you can set the text:
[[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(0.0f, 5.0f) forBarMetrics:UIBarMetricsDefault];
Use the offset to change the location for the text

The little solution i found is to use UIButton instead of UIBarButton.
UIButton will align correctly to the UIToolBar(with/without changed height).

Related

UIBarButtonItem is shrinked on iPhone 4 inch

Why it happens like this?
The last one "plus" is just an ADD System Item.
Is there a way to prevent from such issue?
In UINavigationBar the space between items is fixed and you either have to set rightNavigationItems array or leftNavigationItems array. Then you don't have opportunity to adjust spacing between items yourself. If you have customized view and UINavigationBar is not inside a UINavigationController then probably you can replace it with UIToolbar and add FlexibleSpace between each item. It will give you the same result but also it will adjust itself according to screen width.
I added 7 buttons in interfacebuilder the upper one is UINavigationBar and lower one is UIToolbar with FlexibleSpace item between each UIBarButtonItem
And This is what I got the result on iPhone4 Simulator
It looks like the space for the "add" item is a bit smaller and leads the item to internally used textfield less space making the text shrink to fit size, its only a guess.
Maybe/surly you can solve the issue using a custom item, but this would obviously not explain what is going on...

Shifting backButtonImage horizontally

What I need,
What I get, on adding backButtonImage,
I want to shift the backButtonImage horizontally? No answers on here seem to work for me.
Any suggestions will be welcomed.
EDIT
I am just setting back image and back mask in storyboard, here it is (nav_back)
Have a look at UIBarButtonItem Size Inspector in storyboard.
You should be able to shift image to the right by X points by setting image left inset to X and right inset to -X. This worked with bar button item with custom image but not sure if it will with default back button

-[UIBarButtonItem setTitlePositionAdjustment:forBarMetrics:] ignores vertical offset

I have an application with some custom positioned bars, and as such I'd like to change the standard vertical alignment of the button text. I've tried setting
[buttonItem setTitlePositionAdjustment:UIOffsetMake(0, -22) forBarMetrics:UIBarMetricsDefault]
but nothing changes. Oddly, if I set a horizontal offset, the button moves just fine. It appears only vertical alignment changes are not being respected. Is this a bug on iOS 7? Am I misunderstanding something about the API? I see no documentation saying that the vertical alignment is ignored.
(example project showing the issue)
Unfortunately setTitlePositionAdjustment:forBarMetrics: doesn't appear to take effect. The best workaround I found was to use a UIButton instead, which can be done right in Interface Builder.
Add a UIButton to the UIBarButtonItem and set the font or image, size, etc.
In the Attributes Inspector, set the UIButton's control alignment to right
Hook the button back up to whatever actions you need

uitoolbar with icons/text similar to uitabbar

Ideally I want to use a UIToolbar but I want the icons at the bottom to appear as they would in a UITabBar meaning with icon for default and highlighted states and title beneath. I know I can drag a UIButton onto the toolbar and it will create a UIButton inside of a UIBarButtonItem, but I can't seem to manipulate the UIButton to show a title beneath? The other problem I'm having is when I set the alignment of the button in IB (in the Control section) it only changes the alignment for the default state not the highlighted state. Can anyone give me some pointers here that would be great thanks!
rc
Putting the UIButton inside a UIBarButtonItem is the best way I've found to do it. Just set the text for the button and it should show up fine. When manipulating the positioning, remember you're manipulating the position of the UIBarButtonItem and not the UIButton. Hope that helps!

UINavigationBar right button too tall

I'm using custom images for UINavigationBars and UIToolbars. The problem i'm having is on 1 of my views that uses a UINavigationBar, the right button appears too tall
On the views that use a UIToolbar (modal views so no Nav bar) they look fine
What could be causing the button to be too large? I've tried adding the button in IB and also using code. Then set the image like this
UIImage *barButton = [[UIImage imageNamed:#"ButtonBlue"] resizableImageWithCapInsets:UIEdgeInsetsMake(6, 8, 6, 8)];
[self.connectButton setBackgroundImage:barButton forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
Thanks
Create a smaller button. You can do this in Preview - resize it. Make sure you have #2x sizes too. T cannot recall the recommended size for theses images - it's something like 30 points or so (search and you'll find it for sure).

Resources