I would like to know if there is a way to detect the current font and size used by iOS for the title shown in the navigation bar.
Is it possible to detect what Font (name and size) it's been used by the system?
Yes. You can run through all subviews of the navigation bar and find displayed labels, then you can get the font.
Related
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)
I've noticed that the default, back button for view controllers embed in a navigation controller does not scale per device size. Is there anyway I'd be able to adjust the font size of the back button depending on the device size?
The back button is a bar button item. No bar button item will automatically "scale per device size". You are free to apply your own title text attributes to the back button, just as you would do for any other bar button item:
https://developer.apple.com/documentation/uikit/uibaritem/1616414-settitletextattributes
Note, however, that it is not usual to have different text sizes on difference devices, and users might be surprised by it.
I am using SWRevealViewController class to implement side-out slide bar. I followed this link and side bar is coming.
But I want to change the text colour and size of item texts of slide bar. Any idea how to do it?
I couldn't find any way to update it. Though there are parameters to update the size of window (_initDefaultProperties) but not the item text.
I've implemented a Navigation Controller for my View Controller with storyboard. Now i want changing navigation bar title font and size with Attribute Inspector but it doesn't work and i don't understand why. Title color changes but font dont.
ps: the color changing is visible only at runtime and not in the storyboard.
You need to select navigation Bar and then you can set relevant properties. Please check attached image. It might help you.
When I tried to set the font, my font field was grayed out. But all I needed to do was change type to System and then again to Custom. It worked:-) Now I can choose my custom font
For me Bartłomiej Semańczyk's change to system font & change back trick only works to set the font to a particular system-included font. For custom fonts that I've added, the font face gets set to my custom font but it always gets displayed as size ~16 or so regardless of what size I select in the storyboard.
So the best way I can find to do this is to set self.navigationController.navigationBar.titleTextAttributes in the view controller's viewDidLoad method.
Note that you don't need to do this in every view controller you push onto this navigation stack, just the first one that gets displayed since it sets the property on the navigationBar itself not on the navigationItem. If you're subclassing UINavigationController already, that's the most logical place to set this but I'd rather not subclass it just for this one line change.
I converted app to iOS7 by Xcode5 GM.
And I noticed button's UI none-border also increasing font size for navigation bar button.
My question is, why increase font size of navigation bar button on ios7?
There has a rule something?