3

I am using the JSQmessageviewcontroller, but i want the bubbles to have no tail, just to be rounded rectangles, is this possible? I currently do something like:

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

I would like it to look something like:

enter image description here

Also is there a way to adjust the distances between the two bubble?

Patrick Klitzke
  • 1,519
  • 2
  • 14
  • 24

2 Answers2

5

Ya what you want to do is make pass the tailless image into your JSQMessagesBubbleImageFactory for

Objective C:

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

Swift:

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

As for making the distance between messages you just need to changed the height of the upper label objective C:

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

Swift:

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

Swift 3:

JSQMessagesBubbleImageFactory(bubble: UIImage.jsq_bubbleCompactTailless(), capInsets: .zero)
Dan Leonard
  • 3,325
  • 1
  • 20
  • 32
2

In Swift 3.0

JSQMessagesBubbleImageFactory(bubble: UIImage.jsq_bubbleCompactTailless(), capInsets: .zero)
Sanf0rd
  • 3,644
  • 2
  • 20
  • 29
  • 1
    I'm using this exactly version: Version 8.1 (8B62). Are you using cocoaPods? – Sanf0rd Dec 04 '16 at 17:11
  • 1
    very Thanks that you replied, but code is working now, and Yes, I'm using cocoaPods . this blog helped me- https://www.syncano.io/blog/create-ios-chat-app-part1/ – Ankit Kumar Dec 04 '16 at 18:31