Any one know how to remove the UIButton
underline that appears because of Accessibility?
(I know it\'s because the user turned on \"Button Shapes\")
Check below code
:
NSMutableAttributedString *attrStr = [[yourBtnHere attributedTitleForState:UIControlStateNormal] mutableCopy];//or whatever the state you want
[attrStr enumerateAttributesInRange:NSMakeRange(0, [attrStr length])
options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired
usingBlock:^(NSDictionary *attributes, NSRange range, BOOL *stop)
{
NSMutableDictionary *mutableAttributes = [NSMutableDictionary dictionaryWithDictionary:attributes];
[mutableAttributes removeObjectForKey:NSUnderlineStyleAttributeName];
[attrStr setAttributes:mutableAttributes range:range];
}];
• With the inspector/IB:
Select your UIButton
.
Show the Attributes Inspector
.
The Text
settings should be in Attributed
. Select the text, click on the fond item remove the Underlining setting it at none
.
You should go to Settings > General > Accessibility and turn on/off Button Shapes and then revisit the app in question. You should only see underlines and shapes when this control is on, and this is to indicate what buttons that look like text are actually tappable for those with accessibility needs.
To remove the unwanted Blue colour layer from UIButton
in simulator
go to Settings > General > Accessibility and turn off Button Shapes and then reRun the app it will remove the unwanted blue layer.