IOS 文本操作获取显示文本宽度
来源:互联网 发布:业主信息采集软件 编辑:程序博客网 时间:2024/04/29 13:56
NSGraphicsContext* newCtx = [NSGraphicsContext graphicsContextWithGraphicsPort:bitmapContext flipped:true];[NSGraphicsContext saveGraphicsState];[NSGraphicsContext setCurrentContext:newCtx];NSAttributedString *string = /* make a string with all of the desired attributes */;[string drawInRect:locationToDraw];
[NSGraphicsContext restoreGraphicsState];
int charCount = [string length]; CGGlyph glyphs[charCount]; CGRect rects[charCount]; CTFontGetGlyphsForCharacters(theCTFont, (const unichar*)[string cStringUsingEncoding:NSUnicodeStringEncoding], glyphs, charCount); CTFontGetBoundingRectsForGlyphs(theCTFont, kCTFontDefaultOrientation, glyphs, rects, charCount); int totalwidth = 0, maxheight = 0; for (int i=0; i < charCount; i++) { totalwidth += rects[i].size.width; maxheight = maxheight < rects[i].size.height ? rects[i].size.height : maxheight; } dim = CGSizeMake(totalwidth, maxheight);
0 0
- IOS 文本操作获取显示文本宽度
- js获取文本显示宽度
- IOS 获取文本的高度和宽度
- iOS UILabel 展示不下,显示 xxx... 时,获取容纳字符文本真正的宽度
- 提前获取文本的宽度,便于合理显示文本显示框
- iOS中获取文本的高度与宽度
- 控件显示文本宽度自适应
- 获取文本宽度和高度
- IOS动态获取文本的高度--自适应文本宽度、高度Textview
- iOS 获取label或button文本的宽度,让button自适应titlelabel的宽度
- iOS 显示HTML文本
- ios获取文本长度
- 获取文本高度 ios
- iOS 文本操作
- 获取Text文本的高度和宽度
- 获取文本内容高度和宽度
- jquery获取文本的宽度和高度。
- IOS Swift3.1 获得文本宽度
- iOS下OpenGL ES 3.0编程入门(二 ):画一个简单三角形
- SSL介绍
- iOS开发_统计xcode代码行数
- 多态应用实例1
- Swift2.0中使用闭包表达式进行类之间进行通信
- IOS 文本操作获取显示文本宽度
- 优化ListView提升运行效率
- python偏函数
- 高精度之重载运算符
- iOS 面试题
- Tigase开发笔记3:Tigase 参数配置说明
- 浅析C#中的Func<>委托
- MFC隐藏对话框 (会闪)
- IOS学习第二篇 ——引用计数器内存管理