Mit*_*iya 10 cocoa-touch uibutton ios ios7.1
任何人都知道如何删除UIButton由于辅助功能而出现的下划线?
(我知道这是因为用户打开了"按钮形状")

如何以编程方式删除它,或通过在Xcode中设置一些属性?
Dun*_*n C 13
让我说清楚.Apple添加了一个辅助功能,允许用户在需要时用下划线标记按钮.
您想要一种方法来击败此功能,专门用于帮助有障碍的人使用他们的设备,当功能是用户必须要求的东西时.
为什么?
使用标准按钮很可能无法实现.如果你确实找到了办法,Apple可能会拒绝你的应用程序,因为它会破坏一个旨在帮助残疾人的系统功能.
所以答案是:不要这样做.
Abh*_*tap 10
您应该转到设置>常规>辅助功能,然后打开/关闭按钮形状,然后重新访问相关应用程序.打开此控件时,您应该只看到下划线和形状,这是为了指示那些看起来像文本的按钮实际上可以替代那些具有辅助功能需求的按钮.
检查如下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];
}];
Run Code Online (Sandbox Code Playgroud)
•使用检查员/ IB:选择您的UIButton.
显示Attributes Inspector.
该Text设置应该是Attributed.选择文本,单击喜欢的项目删除下划线设置它none.

小智 7
将背景图像设置为按钮.
[yourBtnHere setBackgroundImage:[[UIImage alloc] init] forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13252 次 |
| 最近记录: |