Reputation: 3259
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.
Upvotes: 4
Views: 1619
Reputation: 4656
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);
Hope that help!
Upvotes: 2