-boundingRectWithSize:options:attributes:context:用法
来源:互联网 发布:系统修复软件 编辑:程序博客网 时间:2024/06/09 14:25
导入第三方一些类库后,出现一些警告就是某些方法被弃用了:
如:
- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(NSLineBreakMode)lineBreakModeNS_DEPRECATED_IOS(2_0,7_0,"Use -boundingRectWithSize:options:attributes:context:");
提示用:boundingRectWithSize:options:attributes:context:这个方法
这个方法:
- (CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options attributes:(NSDictionary *)attributes context:(NSStringDrawingContext *)context
几个参数:
size:范围自己决定options :这是一个枚举类型
typedefNS_ENUM(NSInteger, NSStringDrawingOptions) {
NSStringDrawingTruncatesLastVisibleLine = 1 << 5,
NSStringDrawingUsesLineFragmentOrigin = 1 <<0,
NSStringDrawingUsesFontLeading = 1 <<1,
NSStringDrawingUsesDeviceMetrics = 1 <<3,
} NS_ENUM_AVAILABLE_IOS(6_0);
自己选一个适合的
attributes:字典NSDictionary *attributes = @{NSFontAttributeName:[UIFontsystemFontOfSize:20]};
context:文本绘制的规范定义,一半为nil就可以
替换后:
NSDictionary *attributes = @{NSFontAttributeName:[UIFontsystemFontOfSize:20]};
CGSize textSize = [@"字符串" boundingRectWithSize:CGSizeMake(100, 100) options:NSStringDrawingTruncatesLastVisibleLine attributes:attributes context:nil].size;
每天积累一点点....
- -boundingRectWithSize:options:attributes:context:用法
- -boundingRectWithSize:options:attributes:context:用法
- -boundingRectWithSize:options:attributes:context:用法
- boundingRectWithSize:options:attributes:context:
- boundingRectWithSize:options:attributes:context:
- boundingRectWithSize:options:attributes:context
- 通过boundingRectWithSize:options:attributes:context:计算文本尺寸
- iOS7 中 boundingRectWithSize:options:attributes:context:计算尺寸的使用
- boundingRectWithSize:options:attributes:context:计算尺寸的使用
- iOS7 中 boundingRectWithSize:options:attributes:context:计算尺寸的使用
- UILabel自适应大小的新方法boundingRectWithSize:options:attributes:context:
- TextKit学习 通过boundingRectWithSize:options:attributes:context:计算文本尺寸
- 学习boundingRectWithSize:options:attributes:context:计算文本尺寸
- 通过boundingRectWithSize:options:attributes:context:计算文本尺寸
- iOS方法:boundingRectWithSize:options:attributes:context:(计算文本尺寸)
- boundingRectWithSize:options:attributes:context:代替sizeWithFont:constrainedToSize:lineBreakMode:
- boundingRectWithSize:options:context:
- TextKit学习(四)通过boundingRectWithSize:options:attributes:context:计算文本尺寸
- poj_3259
- unity3d 4.6RectTransform 的一些设置
- 触发器判断更改的行或列
- android内置浏览器不支持websocket的解决方法
- Android 打造炫目的圆形菜单 秒秒钟高仿建行圆形菜单
- -boundingRectWithSize:options:attributes:context:用法
- 基础的数论知识
- perl 多线程及信号控制
- 解析apache的httpd.conf配置内容
- Andoird 监听开机广播和关机广播
- 为接下来的3年而奋斗
- 建立本类特有的判断对象是否相同的依据
- java CyclicBarrier
- iOS App Icons for iOS 8