(CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options attributes:(nullable NSDictionary<NSAttributedStringKey, id> *)attributes context:(nullable NSStringDrawingContext *)context
(CGRect)boundingRectWithSize:(CGSize)size options:(NSStringDrawingOptions)options context:(nullable NSStringDrawingContext *)context
size:限制尺寸,用于计算文本绘制时占据的矩形块
option:文本绘制时的附加选项。
有四种类型:
1.NSStringDrawingTruncatesLastVisibleLine
2.NSStringDrawingUsesLineFragmentOrigin
3.NSStringDrawingUsesFontLeading
4.NSStringDrawingUsesDeviceMetrics
通常使用NSStringDrawingUsesLineFragmentOrigin,
attributes:富文本字典,例如@{NSFontAttributeName : font}
context context上下文。包括一些信息,例如如何调整字间距以及缩放。该参数可为 nil