gpt4 book ai didi

ios - 如何在 boundingRectWithSize 中指定 NSLineBreakMode?

转载 作者:可可西里 更新时间:2023-11-01 05:04:32 25 4
gpt4 key购买 nike

 [text boundingRectWithSize:BOLIVIASize options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:FONT} context:nil];

这是新的替代品

- (CGSize) sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode) lineBreakMode

但是,如何在 boundingRectWithSize 上指定 lineBreakMode 参数?

最佳答案

使用 NSParagraphStyleAttributeName & NSParagraphStyle:

NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
paragraph.lineBreakMode = NSLineBreakByWordWrapping; //e.g.

CGSize size = [label.text boundingRectWithSize: constrainedSize options:NSStringDrawingUsesLineFragmentOrigin attributes: @{ NSFontAttributeName: label.font, NSParagraphStyleAttributeName: paragraph } context: nil].size;

关于ios - 如何在 boundingRectWithSize 中指定 NSLineBreakMode?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20631464/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com