0
UILabel
のフレームに収まるNSString
の部分文字列を取得しようとしています。私はCGRectを得るために、このコードを使用しています -boundingRectWithSizeは常に同じCGRectを返します
CGSize sizeConstraint = CGSizeMake(355, 293.09375);
NSMutableParagraphStyle *paraStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paraStyle.lineBreakMode = NSLineBreakByWordWrapping;
NSDictionary *attributes = @{ NSFontAttributeName : bodyFont, NSParagraphStyleAttributeName : paraStyle};
NSAttributedString *attributedText = [[NSAttributedString alloc] initWithString:body attributes:attributes];
CGRect boundingRect = [attributedText boundingRectWithSize:sizeConstraint options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading) context:nil];
問題I AMフェーシングはboundingRectWithSize
文字列の一定量の後に同じCGRrectを返すということです。
(CGRect) boundingRect = (origin = (x = 0, y = 0), size = (width = 352.515625, height = 281.25))
そしてCGRect文字列が1354の文字長い場合私が取得 - -
(CGRect) boundingRect = (origin = (x = 0, y = 0), size = (width = 352.515625, height = 281.25))
ええ、私はdownvoteに値する – genaks