Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.0k views
in Technique[技术] by (71.8m points)

iphone - sizeWithFont:constrainedToSize:lineBreakMode deprecated

I have the following code:

float height = [string sizeWithFont:[UIFont systemFontOfSize:kFontSize] constrainedToSize:CGSizeMake(widthOfTextView, 999999.0f) lineBreakMode:NSLineBreakByWordWrapping].height + verticalPadding;

However, whenever I run my application and get a warning telling me that this is deprecated. What should I use and how would I use it with my current code?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

sizeWithFont:ConstrainedToSize:lineBreakMode is deprecated as of iOS 7, so I've also been searching high and low for the replacement. This seems to be the best answer I've found so far:

https://stackoverflow.com/a/18746573/1275947


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...