我在 uiview 中使用 UIBezierpath 绘制消息气泡。我在贝塞尔路径内渲染文本视图。我的问题是当我在 textview 中输入文本时,我想动态增加消息气泡大小,但我不能这样做。如何解决这个问题。
问问题
1541 次
1 回答
2
您可以调整 UIBezierpath 相对于您的 UITextview 框架大小,如下所示:
CGRect box = CGPathGetBoundingBox(bezierpath.CGPath)
CGFloat scaleX = textView.frame.size.width / box.frame.size.width;
CGFloat scaleY = textView.frame.size.height / box.frame.size.height;
CGAffineTransform transform = CGAffineTransformMakeScale(scaleX, scaleY);
CGPathRef intermediatePath = CGPathCreateCopyByTransformingPath(bezierpath.CGPath, &transform);
bezierPath.CGPath = intermediatePath;
CFRelease(intermediatePath);
希望有帮助!
于 2012-11-23T06:40:33.867 回答