要计算使用排除路径和NSAttributedString的UITextVIEw的大小,可以执行以下 *** 作:
// Assuming something like this...UIBezIErPath * exclusionPath = [UIBezIErPath bezIErPathWithRect:someRect];self.textVIEw.textContainer.exclusionPaths = @[exclusionPath];NSAttributedString * attributedString = ...self.textVIEw.attributedString = attributedString;...// Use text container,layout manager,and text storage associated with the text vIEw.NSTextContainer * textContainer = self.textVIEw.textContainer;NSLayoutManager * layoutManager = textContainer.layoutManager;NSTextStorage * textStorage = layoutManager.textStorage;// limit the wIDth or height. In this case,limiting the wIDth to 280.textContainer.size = CGSizeMake(280.0,FLT_MAX);[textStorage setAttributedString:attributedString];// Because the layout manager performs layout lazily,on demand,you must force it to lay out the text,even though you don’t need the glyph range returned by this function.[layoutManager glyphRangeForTextContainer:textContainer];// Ask the layout manager for the height of the rectangle occupIEd by the laID-out textCGfloat height = [layoutManager usedRectForTextContainer:textContainer].size.height;
Apple Documentation
总结以上是内存溢出为你收集整理的ios – 使用排除路径计算TextView的单元格高度全部内容,希望文章能够帮你解决ios – 使用排除路径计算TextView的单元格高度所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)