UIBarButtons styled with System Items, disappear after rotation - ios

In our app the initial ViewController is embedded in a regular Navigation Controller. We have two UIBarButtons, located in the upper right of the navigationbar. One of the buttons is styled with a custom image and the other one with the camera icon from the provided System Items.
Here is the problem:
When the app starts in portrait, both bar buttons are visible. After rotating the device to landscape, the UIBarButton with the camera symbol disappears and no longer shows up when rotating back to portrait again.
I have no outlets to neither the navigationbar nor the UIBarButtons, no adjustments in code are made whatsoever.
The button that disappears after rotation still exists in the navigationbar, if you tap where it is supposed to be shown, the action is triggered. It seems to only be the image that is removed for some reason. And only if the button is styled with any of the System Items.
Can anyone think of a reason why this problem occurs?

Ok, this problem was related to appearance proxy code that I had in my appDelegate:
[[UITextField appearance] setTintColor:[UIColor darkGrayColor]];
[[UITextView appearance] setTintColor:[UIColor darkGrayColor]];
Apparently these two statements affect the behaviour of the barbutton appearance. I cannot see why, but I am sure that there is a good reason.
Getting rid of these two statements in the appDelegate solved the problem.

Related

Bold Text accessibility option hides UIButtonBarItem graphics

This is a follow-up to a question I asked last week here. The main screen of my app has two button bars. Each of the buttons has either an image or a text label. I've determined that when the user has the Bold Text Accessibility option enabled, the image buttons disappear from the screen. The buttons are functional -- tapping where the button should appear has the desired effect, so the button is effectively present but invisible. The text-based buttons appear and function normally.
Is this expected behavior, or is this a bug in the iOS implementation? If it's a bug, is there a procedure to report it? Is there a workaround? My fallback solution is to display a warning based on UIAccessibilityIsBoldTextEnabled(), but I would like to do better.
I have just had the issue reported to me by one of my customers. I can replicate the issue on iOS12 however Apple appear to have fixed it in iOS13.
My workaround for iOS12 is to set the tintColor of the toolbar:
[toolbar setTintColor:[UIColor grayColor]];
With the tintColor set the toolbar buttons are visible with Bold Text on.

Attached iOS 11-style UISearchBar background image

I'd like to migrate my tableHeaderView based search bar to the new seamless search bar approach in iOS 11 by configuring navigationItem.searchController.
Since my navigation bar uses a custom background image, I'm wondering how to apply the same background image to the search bar as well. I tried
[navigationBar setBackgroundImage:[UIImage imageNamed:#"NavigationBarPromptBackground"] forBarMetrics:UIBarMetricsDefaultPrompt];
[searchBar setBackgroundImage:[UIImage imageNamed:#"NavigationBarBackground"] forBarPosition:UIBarPositionAny barMetrics:UIBarMetricsDefault];
to no avail. The search bar keeps the standard navigation bar background (with a barTintColor applied) but doesn't show the custom background image.
In my case I have a UISearchBar in a view, not placed in a UINavigationItem. A transparent background image I was setting wasn't showing up in iOS 11. However if I add a height constraint that forces the searchBar to be smaller the background image gets used for some reason. This is really odd behavior that must be a bug but it is working for me now.
If I do the following the background image gets used:
[[searchBar.heightAnchor constraintEqualToConstant:44.0] setActive:YES];
I do a very similar thing in my application and discovered on IOS11 it's now broken. This is the code I had which sets my image across the Search and Scope bars, works fine up to IOS10:
[searchBarSearch setBackgroundImage:image];
[searchBarSearch setScopeBarBackgroundImage:image];
I fixed it by adding this to the .plist
View controller-based status bar appearance = NO
Now my bar is coloured and changes as I select different options as it did before IOS11.
Hope this helps you!
Plasma

UIPopoverController iOS 8.3 - UIBarButtons and UISegmentedControl not shown after dismiss

In our app when we present a UIPopoverController, after we dismiss it, if we navigate to any other screens that have barButtonItems or segmentedControls, these are not showing but they are intercepting the touch, so tapping on them works.
Even when we navigate to a new UINavigationController, it still doesn't work.
The navigationBar is visible, but the buttons or the segmentedControls on the view controller's view are not.
The weird thing is that if I enable Color Blended Layers I can see the buttons / segmentedControl.
It happens on multiple screen in our app where we have bar buttons or segmentedControls.
It happens only on iOS 8.3 (we build the app with iOS 8.3 SDK). We tried both presenting the pop over programatically and using the Present as Popover Segue.
The same code works on iOS < 8.3.
Has anyone encountered this issue?
I have attached some screenshots.
I found the issue.
It seems that the tint color of the UIWindow(blue) was overriding the tint color of the UINavigationBar (white) so the UIBarButtonItems were actually blue.
I was setting them both in AppDelegate using UIAppeareance.
The solution was to avoid setting the tint color to the UIWindow and set it directly to the UIView subclasses that I was interested in (UITableView and UIButton)
I have no idea why this happened only after I dismissed the popover and only in iOS 8.3

Set navigation bottom bar color programatically

Is there away i can set the colour of may navigationController bottom bar colour. Similar to setting top bar in the app delegate with
[[UINavigationBar appearance]setBackgroundColor:color];
can bottomBarColor or something be used?
thanks
The problem is you mistakenly believe that the bar you see at the bottom is a real bar instance/object.
It is not, it is just a simulation of a future situation.
With bar metrics feature in Interface Builder, you can simulate a situation when you view controller will be a part of larger view hierarchy which will contain a bar at a bottom. You can simulate this in design time, and this way you can adjust your AutoLayout constraints, or frames, as if the bar was there so this way the constraints/ frames will behave correctly when it really happens.
If you want a bar with orange colour, you need to have a real bar instance added to some view controller, and change its appearance. But I repeat, it needs to be a real bar instance, not a bar metrics simulation.
Btw, it is AFAIK not possible to put a navigation bar to the bottom, for that you need to use UIToolbar class.
If you want to set the toolbar color globally do this in your AppDelegates didFinishLanchingWithOptions method:
[[UIToolbar appearance] setBarTintColor:[UIColor blackColor]];
Of course your selected color doesn't have to be black.

Adding translucent toolbar to navbar causes rendering issue in iOS 7

I have an iOS app that I want to to add more than just 2 items to my navigation bar. One way I have read to do this is to add a toolbar one of your bar button items and then add however many items you want to the toolbar. This seems to work well, except my navbar is translucent (iOS 7 default). This causes the toolbars opacity to overlap with the navbar, causing a noticeable white square if the user scrolls dark content underneath the navbar.
If I could get the toolbar background to be clear, then this would resolve my problem. Does anyone know how to do this, or another way around this issue? Just setting the background of the toolbar to clear does not seem to work.
How about
toolbar.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.1];

Resources