How to redraw text text text based on UIBezierpath on iPhone

I draw a message bubble using the UIBezierpath in uiview. I render the text inside the bezier path. My problem is that when I enter text in text form, I want the size of the message bubble to dynamically increase, but I cannot do this. how to solve the problem.

+4
source share
1 answer

You can resize the UIBezierpath relative to your UITextview frame size as follows:

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

Hope that helps!

+2
source

All Articles