In one of my Chatting app i have used label and textview. UITextView is center Align and one more label add to subview and adjusting there position according text that is working fine..
But my need is to make it similar to whatsapp application. if text is to small and label can adjust within same line than bubble should not expand to two line and adjust in single line..
i have attached image that will clear the requirement.
Thanks in advance.
I am able to perform this with help of Textkit- exclusionPaths.
CGSize sizelbl = _lbl_Timestamp.frame.size;
[_lbl_Timestamp
setFrame:CGRectMake(CGRectGetMaxX(_txtView.frame) - sizelbl.width - 5,
CGRectGetMaxY(_txtView.frame) - sizelbl.height - 5 - 3,
sizelbl.width, sizelbl.height)];
CGRect ovalFrame = [_txtView convertRect:_lbl_Timestamp.bounds fromView:_lbl_Timestamp];
// Since text container does not know about the inset, we must shift the frame to container coordinates
ovalFrame.origin.x -= _txtView.textContainerInset.left;
ovalFrame.origin.y -= _txtView.textContainerInset.top;
// Simply set the exclusion path
UIBezierPath *ovalPath = [UIBezierPath bezierPathWithOvalInRect: ovalFrame];
_txtView.textContainer.exclusionPaths = @[ovalPath];