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")
How can I remove that programmatically, or by setting some property in Xcode?
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
.