NSRange theTextRange = [[theTextVIEw layoutManager] glyphRangeForCharacterRange:[theTextStorage editedRange] actualCharacterRange:NulL];NSRect theTextRect = [[theTextVIEw layoutManager] boundingRectForGlyphRange:theTextRange inTextContainer:[theTextVIEw textContainer]];解决方法 boundingRectForGlyphRange:inTextContainer:返回的rect位于容器坐标中.如果要相对于文本视图获取rect,则需要对此进行调整:
NSRange theTextRange = [[textVIEw layoutManager] glyphRangeForCharacterRange:textRange actualCharacterRange:NulL];NSRect layoutRect = [[textVIEw layoutManager] boundingRectForGlyphRange:theTextRange inTextContainer:[textVIEw textContainer]];NSPoint containerOrigin = [textVIEw textContainerOrigin];layoutRect.origin.x += containerOrigin.x;layoutRect.origin.y += containerOrigin.y;总结
以上是内存溢出为你收集整理的cocoa – NSTextView中字符的NSPoint / NSRect全部内容,希望文章能够帮你解决cocoa – NSTextView中字符的NSPoint / NSRect所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)