JSQMessagesCollectionView - How to force the attributedTextForMessageBubbleTopLabelAtIndexPath to 100% width?

268 views Asked by At

I am using JSQMessagesCollectionView and applying the attributedTextForMessageBubbleTopLabelAtIndexPath

However I have noticed that my text doesn't appear to be in 100% of the width and seems to be placed in an offset.

Picture:

enter image description here

In the above picture shows the attributedTextForMessageBubbleTopLabelAtIndexPath in action; it appears to have an offset; I do not set an alignment, tab stop or anything like that.

How do I turn this offset off and make it 100% width so that I may align my text centrally.

Many thanks

1

There are 1 answers

0
Mohammad Zekrallah On BEST ANSWER

I'm using C# ported version of the library but you an get the concept.

Adjust below line in in CellForRowAtIndexPath to put the insets you want :

cell.MessageBubbleTopLabel.TextInsets = new UIEdgeInsets (0.0f, bubbleTopLabelInset, 0.0f, 0.0f);

and in JSQMessagesCollectionViewCellIncoming set the alignment in AwakeFromNib :

    public override void AwakeFromNib ()
    {
        base.AwakeFromNib ();
        this.MessageBubbleTopLabel.TextAlignment = UITextAlignment.Center;
    }