JSQmessageviewcontroller:没有尾巴的气泡

时间:2016-02-15 13:26:07

标签: ios objective-c jsqmessagesviewcontroller

我正在使用JSQmessageviewcontroller,但我希望气泡没有尾部,只是为了圆角矩形,这可能吗?我目前做的事情如下:

JSQMessagesBubbleImageFactory *bubbleFactory = [[JSQMessagesBubbleImageFactory alloc] init];
self.outgoingMessageBubble = [bubbleFactory incomingMessagesBubbleImageWithColor:[UIColor colorWithRed:0.949 green:0.949 blue:0.949 alpha:1]];

我希望它看起来像:

enter image description here

还有办法调整两个泡泡之间的距离吗?

2 个答案:

答案 0 :(得分:5)

雅你想要做的是将无尾图像传递到你的JSQMessagesBubbleImageFactory

目标C:

JSQMessagesBubbleImageFactory *bubbleFactoryOutline = [[JSQMessagesBubbleImageFactory alloc] initWithBubbleImage:[UIImage jsq_bubbleRegularStrokedImage] capInsets:UIEdgeInsetsZero];

夫特:

JSQMessagesBubbleImageFactory(bubbleImage: UIImage.jsq_bubbleCompactTaillessImage(), capInsets: UIEdgeInsetsZero). 

至于在消息之间建立距离,您只需要更改上标签的高度 目标C:

(CGFloat)collectionView:(JSQMessagesCollectionView *)collectionView
               layout:(JSQMessagesCollectionViewFlowLayout *)collectionViewLayout heightForMessageBubbleTopLabelAtIndexPath:(NSIndexPath *)indexPath
{
    return 0.0f;
}

夫特:

override func collectionView(collectionView: JSQMessagesCollectionView!, layout collectionViewLayout: JSQMessagesCollectionViewFlowLayout!, heightForMessageBubbleTopLabelAtIndexPath indexPath: NSIndexPath!) -> CGFloat {
    return 20
}

斯威夫特3:

JSQMessagesBubbleImageFactory(bubble: UIImage.jsq_bubbleCompactTailless(), capInsets: .zero)

答案 1 :(得分:2)

在Swift 3.0中

JSQMessagesBubbleImageFactory(bubble: UIImage.jsq_bubbleCompactTailless(), capInsets: .zero)