简体   繁体   English

sizeWithFont:iOS7中已弃用minFontSize

[英]sizeWithFont: minFontSize is Deprecated in iOS7

- (CGFloat)heightForTitleLabel
{
if (self.titleLabel) {
    CGSize size = [self.title sizeWithFont:self.titleLabel.font
                               minFontSize:
#ifndef __IPHONE_6_0
                   self.titleLabel.font.pointSize * self.titleLabel.minimumScaleFactor
#else
                   self.titleLabel.minimumScaleFactor
#endif
                            actualFontSize:nil
                                  forWidth:CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2
                             lineBreakMode:self.titleLabel.lineBreakMode];
    return size.height;
}
return 0;
}

- (CGFloat)heightForMessageLabel
{
CGFloat minHeight = MESSAGE_MIN_LINE_COUNT * self.messageLabel.font.lineHeight;
if (self.messageLabel) {
    CGFloat maxHeight = MESSAGE_MAX_LINE_COUNT * self.messageLabel.font.lineHeight;
    CGSize size = [self.message sizeWithFont:self.messageLabel.font
                           constrainedToSize:CGSizeMake(CONTAINER_WIDTH - CONTENT_PADDING_LEFT * 2, maxHeight)
                               lineBreakMode:self.messageLabel.lineBreakMode];
    return MAX(minHeight, size.height);
}
return minHeight;
}

Here is my question. 这是我的问题。 I have read other posts about this deprecation in iOS 7, however I can't seem to get them to work for my specific case. 我在iOS 7中阅读了有关此弃用的其他文章,但是我似乎无法让它们在我的特定情况下起作用。 Are there any other alternatives for this problem, and any that would work in this situation? 是否有其他替代方法可以解决此问题,并且在这种情况下可行?

UILabel * label;
label.adjustsFontSizeToFitWidth = YES;
label.minimumScaleFactor = 0.5;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在iOS 7中因过时的sizeWithFont的替换而丢失: - Lost with the replacement for deprecated sizeWithFont: in iOS 7 复制不赞成的sizeWithFont:minFontSize:actualFontSize中的actualFontSize指针返回以获取字体大小的变化吗? - Replicate the actualFontSize pointer return in Deprecated sizeWithFont:minFontSize:actualFontSize to get the change in font size? sizeWithFont:ConstrainedToSize:lineBreakMode:方法在iOS 7中已弃用 - sizeWithFont: ConstrainedToSize: lineBreakMode: method is deprecated in iOS 7 在iOS 7中替换弃用的-sizeWithFont:constrainedToSize:lineBreakMode: - Replacement for deprecated -sizeWithFont:constrainedToSize:lineBreakMode: in iOS 7? UIAccelerometer已弃用ios7 - UIAccelerometer is Deprecated ios7 在iOS7中不推荐使用:AudioSessionSetProperty - Deprecated in iOS7: AudioSessionSetProperty setNeedsDisplayInMapRect-不推荐使用iOS7 - setNeedsDisplayInMapRect - Deprecated iOS7 在iOS 7弃用后如何替换sizeWithFont - how to replace sizeWithFont after it is deprecated on iOS 7 iOS7 弃用 NSString 的 drawAtPoint:forWidth:withFont:minFontSize:actualFontSize:lineBreakMode:baselineAdjustment: - iOS7's deprecation of NSString's drawAtPoint:forWidth:withFont:minFontSize:actualFontSize:lineBreakMode:baselineAdjustment: iOS7:不建议使用drawMapRect方法 - iOS7: method drawMapRect is deprecated
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM