Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can the appearance of Button Shapes enabled through the Accessibility settings be influenced in iOS 7.1?

Tags:

ios

ios7.1

enter image description here

The release of iOS 7.1 brings the availability of Button Shapes under the Accessibility settings. I've noticed that their appearance can be inconsistent within my app. Mostly, I'm getting a black background after having implemented a UIBarButtonItem using Interface Builder. Touching the button but not fully tapping it results in the image turning gray. How can the appearance of the button shapes be influenced so that they will not look so out of place as having a solid black background and more like the gray background as shown in the attached image? In this case I do not want to use a custom control.

like image 993
Daniel Zhang Avatar asked Mar 13 '14 09:03

Daniel Zhang


People also ask

What is button shapes on Iphone settings?

The 'Button Shapes' option in the Accessibility settings enables you to change the appearance of buttons to make them easier to differentiate from text labels. From iOS 7 onwards text buttons use blue text as the default. This can make it difficult for some people to distinguish between buttons and text labels.

What is button shape on Iphone 13?

Answer: A: Button shapes are an accessibility feature that re-creates the outlines found in previous versions of iOS around tappable interface elements and can help increase precision and decrease frustration.


2 Answers

This feature seems to be a little buggy in iOS 7.1. The setting that seems to influence the appearance the most is actually the barTintColor on your UINavigationBar.

Some examples:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    [[UINavigationBar appearance] setBarTintColor:[UIColor lightGrayColor]];

    return YES;
}

When I first launch, the back button looks fine:

enter image description here

Then when I go to landscape, it looks way too dark:

enter image description here

And it then stays too dark when I go back to portrait:

enter image description here

The same thing happens when I use [UIColor orangeColor] as the barTintColor. First it`s fine:

enter image description here

In landscape it gets messed up:

enter image description here

And it then stays that way:

enter image description here

So it clearly looks like a bug in iOS 7.1. One thing that can be done is to set a background image for the back button. This background will then display whether "Button Shapes" is activated or not. Example:

UIImage *backButtonImage = [[UIImage imageNamed:@"back_button.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0.0f, 17.0f, 0.0f, 1.0f) resizingMode:UIImageResizingModeStretch];

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsLandscapePhone];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateHighlighted barMetrics:UIBarMetricsLandscapePhone];

So the big question is: Can we set the button background image when "Button Shapes" is turned on in a way that is independent of the barTintColor?

like image 107
Johannes Fahrenkrug Avatar answered Sep 19 '22 20:09

Johannes Fahrenkrug


-[UINavigationBar setTranslucent:NO] seems to correct this. I don't know why, but it does.

Alas, we couldn't set -[UINavigationBar setTranslucent:] using UIAppearance so had to sprinkle it around the app.

like image 27
jjrscott Avatar answered Sep 20 '22 20:09

jjrscott