JSQMessagesCollectionView - 如何强制将attributionTextForMessageBubbleTopLabelAtIndexPath强制为100%?

时间:2015-06-10 12:24:50

标签: objective-c uicollectionview nsattributedstring

我正在使用JSQMessagesCollectionView并应用  attributedTextForMessageBubbleTopLabelAtIndexPath

但是我注意到我的文字似乎没有100%的宽度,似乎放在一个偏移中。

照片:

enter image description here

在上图中显示attributedTextForMessageBubbleTopLabelAtIndexPath正在行动;它似乎有一个偏移;我没有设置对齐,制表位或类似的东西。

如何关闭此偏移并使其宽度为100%,以便我可以集中对齐文本。

非常感谢

1 个答案:

答案 0 :(得分:1)

我使用的是C#移植版本的库,但是你得到了这个概念。

在CellForRowAtIndexPath中调整下面的行以放置所需的插图:

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

并在JSQMessagesCollectionViewCellIncoming中设置AwakeFromNib中的对齐方式:

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