【发布时间】:2014-11-26 05:29:14
【问题描述】:
我需要计算UITextField 中的行数。
我的UITextField 有一个UIBezierPath 数组,用于沿着UIImage 绘制文本。
UIBezierPath *rect = [UIBezierPath bezierPathWithRoundedRect:_image.frame cornerRadius:0];
[_txt addSubview:_image];
_txt.textContainer.exclusionPaths = @[rect];
显然,行数是不同的,因为有一个排除路径和这种通用方式,
CGSize size = [_txt.text
sizeWithFont:_txt.font constrainedToSize:(CGSize){_txt.frame.size.width, INTMAX_MAX}
lineBreakMode:NSLineBreakByWordWrapping];
返回错误的结果。
注意:_txt 是 UITextField。
谢谢。
测试用例:
【问题讨论】:
标签: ios objective-c iphone uitextfield uibezierpath