剛剛更新到iOS 7我的項目,解決警告棄用像sizeWithFont:爲什麼CustomBadge在iOS 7中以黑色繪製文本?
前:
CGSize stringSize = [badgeString sizeWithFont:[UIFont boldSystemFontOfSize:12]];
後:
CGSize stringSize = [badgeString sizeWithAttributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:12]}];
和文字顏色變成了黑色:
有什麼建議嗎?
代碼比drawns文字是:
[badgeTextColor set];
CGFloat sizeOfFont = 13.5*badgeScaleFactor;
if ([self.badgeText length]<2) {
sizeOfFont += sizeOfFont*0.20;
}
UIFont *textFont = [UIFont boldSystemFontOfSize:sizeOfFont];
CGSize textSize = [self.badgeText sizeWithAttributes: @{NSFontAttributeName:textFont,
NSForegroundColorAttributeName:self.badgeTextColor}];
[self.badgeText drawAtPoint:CGPointMake((rect.size.width/2-textSize.width/2), (rect.size.height/2-textSize.height/2)) withAttributes:@{NSFontAttributeName:textFont}];
我已經添加NSForegroundColorAttributeName:self.badgeTextColor
但它不工作
前... [self.badgeTextColor = [UIColor whiteColor]];
那你明確地設置文字顏色爲別的東西嗎? – chuthan20
默認是白色,我將添加代碼 –