setTitleTextAttributes not working after view on screen. iOS 11 - ios

I've spent a whole day trying to change the colour of a UIBarButtonItem and now i'm thinking it is an iOS 11 bug unless someone can tell me it's by design.
I can change the colour of the text by using this code
[self.refreshButton setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor orangeColor]} forState:UIControlStateNormal];
If I add the code to the viewWillAppear:animated function it works fine, however if you add it to viewDidAppear:animated it does not work.
It seems to work on the iOS 9 simulator, but not iOS 11.
Has something changed in this regard in iOS 11?

If all you want to do is change the title color of your UIBarButtonItem you can set the tintColor property instead of setTitleTextAttributes:. If you want all of your UIBarButtonItems to have the same title color you can set the tintColor of your tool/navigation bar.

I had the same issue on iOS11 but needed to set the font by setTitleTextAttributes. Unfortunately this does also not work by appearance. The only solution I found was to create new BarButtonItems as copy of the old ones and then set them as navigationItem.rightBarButtonItems.
For reference for other users having the same issue.

This Stack Overflow answer may explain why the method doesn't work.
An improper setting of UIControlState() may be the problem.

Related

iOS 13 Navigation Bar Prompt is Always Black

I have read the other posts about the UINavigationBar's Prompt not following the color values of the actual Title. Most of the posts are from the iOS 11 era, and the solutions no longer work on iOS 13.
These are examples of previous posts that no longer have working solutions:
Can't change UINavigationBar prompt color
Change font of prompt in UINavigationController
iPhone: Possible to change the color of just the prompt of the UINavigationBar?
Has anyone else encountered this?
I would suggest the following:
Check that the device is not running in Dark Mode.
Verify that the background-color was not modified anywhere in the code.
Make sure that the style is set to default like in the screenshot below:

UIBarButtonItem tintColor issue while setting bold text on in accessibility

UIBarButtonItem tintColor is not getting change after setting Bold Text On in Settings -> Display & Brightness -> Bold Text.
i am facing this issue in iOS 11 & 12 both. haven't checked in previous versions.
The same question is already asked in apple developer forum but i didn't find any answer there.
https://forums.developer.apple.com/thread/89337
if some one have any work around to this please suggest me.
You can try to do it programmatically using NSAttributedString, I have never done it trough the storyboard, but programmatically using array of [NSAttributedString.Key.font: .systemFontOfSize(size: 25), NSAttributedString.Key.foregroundColor: .blue], etc., works like a charm.
One method that works for me is changing the Global Tint option on the storyboard, of course this is not the perfect solution.

UITabBar has NO background color after transition

I've got this app. When it launches, it asks the user to log in. When you log in, it uses UIViewAnimationOptionTransitionFlipFromRight to transition to a new UIViewController. The issue is, the UITabBar on the view controller has no background color. It is completely transparent. The UITabBar icons are there and it is otherwise fully functional, except that it has no background color.
This happened after I updated for iOS 7.1. Has anyone see this happen? If so, do you know how to fix it?
Apparently this issue has a "fix". This is obviously a bug on Apple's side.
Here is it
This is a bug in iOS 7.1 on Apples's side. The work around is to toggle the translucency on and off. Not the best fix, but it works. We will have to wait until Apple fixes this in 7.2 or later.
tabBar.translucent = NO;
tabBar.translucent = YES;
As answered in this question

IOS 7 Button Background Does Not Work

I have a project that comes from IOS6, and now with the button changes of the IOS7 I had to make a background to my project buttons. Although, when I try to set a background image for my buttons it doesn't work! programming or not it doesn't work!
I tryied:
[buttonOutlet setBackgroundImage:[UIImage imageNamed:#"lineStyleScreen.png"] forState:UIControlStateNormal];
and the IDE! BOTH DONT WORK!!!
I wonder if it is because I did't updated my storyboard to IOS7.
ios 7 doesnt support regular ios 6 buttons. Do follow this link:
http://dev.iachieved.it/iachievedit/?p=127
Is the button type set to Custom in properties inspector?
Try to set the tint color to the button for iOS 7
button.tintColor = [UIColor greenColor];
Note:- set the tint color that will suit to your requirement

Back button is not visible in iOS 7

I have some weird trouble about iOS 7. I have an UINavigationBar in my app and it works perfect for iOS 6;
-- IOS 6 --
However, when i try to run it on iOS 7, my back button disappeared. It's there, still working and clickable but not visible;
-- IOS 7 --
How can I fix this problem ?
Setting BackButtonBackgroundImage via UIAppearance currently has some odd behavior in iOS 7. This is probably related to the updated design, which replaces the rect-style button with a backIndicatorImage (an arrow).
This leaves 3 options for customizing the back button's appearance:
Change the color of the backIndicatorImage by setting the tintColor property on UINavigationBar (or one of its superclasses).
Set the new backIndicatorImage property on UINavigationBar to a custom image. (don't forget to set the backIndicatorTransitionMaskImage as well or it won't work)
Create a custom UIBarButtonItem and manually assign it as UINavigationItem's leftBarButtonItem. (See the answer mentioned above by Mashhadi)
By the way, if you have to keep support ios 6 version like me, use that;
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1)
{
// My iOS 6 back button background
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:39.0f/255.0f green:184.0f/255.0f blue:199.0f/255.0f alpha:1.0];
}
else
{
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
}
I used Wes Dearborn's answer and implemented a nice way of supporting both iOS5+'s back button and iOS7's backIndicatorImage:
Back button strangely disappearing in UINavigationController but keeps working

Resources