如何在iphone中重绘基于UIBezierpath的textview文本内容 [英] How to redraw the UIBezierpath based textview text contentsize in iphone

查看:84
本文介绍了如何在iphone中重绘基于UIBezierpath的textview文本内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在uiview中使用UIBezierpath绘制消息气泡。我在bezier路径中渲染textview。我的问题是当我在textview中输入文本时我想要消息气泡大小动态增加但我不能这样做。如何解决问题。

I draw the message bubble using UIBezierpath in uiview. I render the textview inside the bezier path. My problem is when I enter the text in textview I want to message bubble size dynamically increase but I cannot do that. how can resolve the issue.

推荐答案

您可以调整UIBezier路径相对于您的UITextview帧大小,如下所示:

You can resize the UIBezierpath relative to your UITextview frame size like this:

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);

希望有所帮助!

这篇关于如何在iphone中重绘基于UIBezierpath的textview文本内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆