Open huiyumiao opened 1 year ago
QMUIButton *btn = [[QMUIButton alloc]init]; btn.imagePosition = QMUIButtonImagePositionLeft; btn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 4); [btn setImage:[UIImageMake(imageStr) qmui_imageWithTintColor:JLStyle.mainColor] forState:UIControlStateSelected]; [btn setImage:[UIImageMake(imageStr) qmui_imageWithTintColor:JLStyle.gray99] forState:UIControlStateNormal]; [btn qmui_setTitleAttributes:@{NSFontAttributeName:UIFontBoldMake(16),NSForegroundColorAttributeName:JLStyle.mainColor} forState:UIControlStateSelected]; [btn qmui_setTitleAttributes:@{NSFontAttributeName:UIFontMake(16),NSForegroundColorAttributeName:JLStyle.gray99} forState:UIControlStateNormal]; [btn setTitle:title forState:UIControlStateNormal]; btn.titleLabel.adjustsFontSizeToFitWidth = YES; 在 4.1.3 版本是正常的,升级到最新的 4.6.3 就无效了
QMUIButton *btn = [[QMUIButton alloc]init]; btn.imagePosition = QMUIButtonImagePositionLeft; btn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 4); [btn setImage:[UIImageMake(imageStr) qmui_imageWithTintColor:JLStyle.mainColor] forState:UIControlStateSelected]; [btn setImage:[UIImageMake(imageStr) qmui_imageWithTintColor:JLStyle.gray99] forState:UIControlStateNormal]; [btn qmui_setTitleAttributes:@{NSFontAttributeName:UIFontBoldMake(16),NSForegroundColorAttributeName:JLStyle.mainColor} forState:UIControlStateSelected]; [btn qmui_setTitleAttributes:@{NSFontAttributeName:UIFontMake(16),NSForegroundColorAttributeName:JLStyle.gray99} forState:UIControlStateNormal]; [btn setTitle:title forState:UIControlStateNormal]; btn.titleLabel.adjustsFontSizeToFitWidth = YES;
试试先设置 normal 再设置别的 state 呢?
还是不行
QMUIButton *btn = [[QMUIButton alloc]init]; btn.imagePosition = QMUIButtonImagePositionLeft; btn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 4); [btn setImage:[UIImageMake(imageStr) qmui_imageWithTintColor:JLStyle.mainColor] forState:UIControlStateSelected]; [btn setImage:[UIImageMake(imageStr) qmui_imageWithTintColor:JLStyle.gray99] forState:UIControlStateNormal]; [btn qmui_setTitleAttributes:@{NSFontAttributeName:UIFontBoldMake(16),NSForegroundColorAttributeName:JLStyle.mainColor} forState:UIControlStateSelected]; [btn qmui_setTitleAttributes:@{NSFontAttributeName:UIFontMake(16),NSForegroundColorAttributeName:JLStyle.gray99} forState:UIControlStateNormal]; [btn setTitle:title forState:UIControlStateNormal]; btn.titleLabel.adjustsFontSizeToFitWidth = YES;
在 4.1.3 版本是正常的,升级到最新的 4.6.3 就无效了