I'm trying to have my navigation bar with left and right button (SF Symbols) and title aligned so it looks better visually but text in title view seems to have either some spacing or top alignment there and it makes title look higher which is not what i want. How to make text centered there?
EDIT: Seems it happens when using custom fonts, when i tried system fonts and other custom fonts some of them are displayed correctly
EDIT2: After further investigation it turned out to be the font issue, the one i used is designed not centered, which can be seen even when choosing font from dropdown menu, its not centered in selection either
It's not necessary answer specifically for question in the topic but it is answer for my issue.
It turned out that my problem was caused by custom font which has space below by design. So what i did in the end is to lower navigation title by using this line:
navigationController?.navigationBar.setTitleVerticalPositionAdjustment(CGFloat(5), for: UIBarMetrics.default)
Related
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...
I have noticed that if I instantiate UITableViewCell instances programmatically, specifying the style .value1 (UITableViewCellStyleValue1), the main text label text color is black, but the detail text label text color is a light shade of gray (not quite exactly UIColor.gray or UIColor.lightGray, though).
However, if I use a storyboard with prototype, static cells and set their Style attribute to "Right Detail" (which appears to be the Interface Builder equivalent of .value1), both labels are black.
I can navigate the cell's subviews all the way to the label and change the text color in the attribute inspector, but I'm not sure the color preset is there.
Is there a right way to unify the appearances of cells in both scenarios, while keeping the traditional gray color in the detail text label?
(I would use dynamic cells and instantiate them programmatically, but this one view controller just happens to have these off-the-shelf cells side-by-side with more complex, custom cells.)
I was also annoyed by the same problem.
Finally I found that Xcode 7.3.1 generated a detail text label with text color R:142, G:142, B:147 (#8E8E93).
Xcode 8.2 generates it with black text color. ('Default', to be exact)
Anyway, changing the label's color to R:142, G:142, B:147 (#8E8E93) is an appropriate one, I think so.
I had the same issue and logged a bug report in the Apple Bug Reporter. My bug report was closed with the comments "Duplicate of 28317724 (Open)". I am not sure if bug reports other than your own are visible, the system does not appear to be very transparent.
Hi it's strange behavior in UISearchBar placeholder text alignment while that UISearchbar non-edit mode but that disply fine at editing mode.In non-Edit mode that placeholder text position not displying as center, that text display bit up-side in to UISearchbar like bellow screenshot.
Non-Editing Mode placeholder Looks like:
Editing Mode placeholder Looks like:
As you can see First screenshot that text display bit up-side not look's like second screenshot Center. So i want to make this place Holder text center as search icon Y position.
I just setting search Bar Placeholder text using basic way:
[self.srcbar setPlaceholder:#"Please Enter search Text"];
Please help me in this how can i fix this issue.
What you have described, is technically the default behavior for the search bar. If you'd like to get the text to slide over a bit when editing, you can adjust, in Interface Builder, the offset of the search bar. I've included a screen shot of xcode and the simulator to show you the difference at run time. See the image here: .
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
I have made a custom number pad keypad for my iOS app, but want it to more closely mirror the appearance of the standard keyboard. I am looking for advice on how to make a standard UIButton look and act like the standard keyboard buttons.
Specifically, I need to figure out the following for the iPad and would like to do as much as possible in an xib or storyboard.
The size of the buttons
The color of the keyboard background (or even better, how can I determine this myself?)
The background color of the button
The font and color of the text in the button
How do I add the shadow under the button?
How do I have the button highlight with the grey color instead of blue?
The spacing between the buttons
How do I keep the "group" of buttons centered as a whole when changing the orientation? (all of the resizing options anchor it to a side and not to each other)
Do the standard buttons use images, or do they modify standard UIButton's? Or more appropriately, which is better for us to do?
UPDATE:
I have created a project for the number pad which is a complete working example. However, I have not spent much time on the actual appearance, which is what this question was mainly about. I have posted it on Github and made it an open source project (covered by the MIT licence, so commercial use is allowed as well). Hopefully other people will find it useful, and hopefully others will feel inclined to help make it better and look more like the native keyboard. The Github repository is at:
https://github.com/lnafziger/Numberpad
If you want to do it mostly in IB, then the following can be done:
Size
Colours
Background Color
Font
Text Color
Shadow (to UILabel's not UITextArea)
Spacing
AutoSizing
There is a cool PSD vector kit for all types of iOS elements that should help:
http://www.smashingmagazine.com/2008/11/26/iphone-psd-vector-kit/
Anyway, to the rest of the answers:
Size
Take a screenshot of the buttons and determine the size in Photoshop, or you can use CMD+i on the image file to see the pixel dimensions. Remember to use CMD+Shift+4 and then drag (and then Space to make the screenshot).
Colours
Use the DigitalColor Meter app that's preinstalled on the Mac, it's pretty cool for all kinds of functions.
Background Color for UIButton
The actual UIButton will have a background color of [UIColor clear], however, for the whole keyboard background, it would be best to create something similar in Photoshop and again using color pickers to get the right gradients. Then you could drag this into IB as a background image.
Font
Again, have a look at fonts/try Helvetica
Text Color
[UIColor black]
Shadow:
Programmatically:
[text setShadowOffset:(0,1)]; // One option
[text setShadowOffset:(0,-1); // Another option
[text setShadowColor:[UIColor whiteColor]];
But, you can also set the shadow in the IB inspector for a UILabel.
Button highlight
Look at the UIButton reference
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIButton_Class/UIButton/UIButton.html
Spacing & Rotation
If your using IB, then you could just drag on the buttons to whatever location.. IB has some autosizing options that determine where the buttons are spaced according to the TOP, LEFT, RIGHT and BOTTOM. You can also set if they are stretchable or not.