需要解决的问题
iOS7之后,在 设置->通用->辅助功能->按钮形状 打开后,界面会从
变成
解决办法
- UITabbar
[UITabBar appearance].selectionIndicatorImage = [UIImage new];
- UIButton 给UIButton添加了一个分类
+ (void)load {
//只执行一次这个方法
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
[UIButton changeFontBottomLine];
});
}
#pragma mark - Change Font Bottom Line
+ (void)changeFontBottomLine {
Class class = [self class];
SEL originalSelector = @selector(setTitle:forState:);
SEL swizzledSelector = @selector(CKSetTitle:forState:);
Method originalMethod = class_getInstanceMethod(class, originalSelector);
Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector);
BOOL didAddMethod =
class_addMethod(class,
originalSelector,
method_getImplementation(swizzledMethod),
method_getTypeEncoding(swizzledMethod));
if (didAddMethod) {
class_replaceMethod(class,
swizzledSelector,
method_getImplementation(originalMethod),
method_getTypeEncoding(originalMethod));
} else {
method_exchangeImplementations(originalMethod, swizzledMethod);
}
}
- (void)CKSetTitle:(NSString *)title forState:(UIControlState)state {
[self CKSetTitle:title forState:state];
NSDictionary *attrbiteDic = @{
NSFontAttributeName:self.titleLabel.font,
NSForegroundColorAttributeName:[self titleColorForState:state],
NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone]
};
self.titleLabel.attributedText = [[NSAttributedString alloc] initWithString:title attributes:attrbiteDic];
}