Inherits from UICollectionViewFlowLayout
Declared in JSQMessagesCollectionViewFlowLayout.h

Overview

The JSQMessagesCollectionViewFlowLayout is a concrete layout object that inherits from UICollectionViewFlowLayout and organizes message items in a vertical list. Each JSQMessagesCollectionViewCell in the layout can display messages of arbitrary sizes and avatar images, as well as metadata such as a timestamp and sender. You can easily customize the layout via its properties or its delegate methods defined in JSQMessagesCollectionViewDelegateFlowLayout.

Tasks

Properties

cacheLimit

@property (assign, nonatomic) NSUInteger cacheLimit
Discussion

The maximum number of items that the layout should keep in its cache of layout information.

The default value is 200. A limit of 0 means no limit. This is not a strict limit.

Declared In

JSQMessagesCollectionViewFlowLayout.h

collectionView

@property (readonly, nonatomic) JSQMessagesCollectionView *collectionView
Discussion

The collection view object currently using this layout object.

Declared In

JSQMessagesCollectionViewFlowLayout.h

incomingAvatarViewSize

@property (assign, nonatomic) CGSize incomingAvatarViewSize
Discussion

The size of the avatar image view for incoming messages.

The default value is (30.0f, 30.0f). Set to CGSizeZero to remove incoming avatars. You may use kJSQMessagesCollectionViewAvatarSizeDefault to size your avatars to the default value.

Declared In

JSQMessagesCollectionViewFlowLayout.h

itemWidth

@property (readonly, nonatomic) CGFloat itemWidth
Discussion

Returns the width of items in the layout.

Declared In

JSQMessagesCollectionViewFlowLayout.h

messageBubbleFont

@property (strong, nonatomic) UIFont *messageBubbleFont
Discussion

The font used to display the body a text message in the message bubble of each JSQMessagesCollectionViewCell in the collectionView.

The default value is the preferred system font for UIFontTextStyleBody. This value must not be nil.

Declared In

JSQMessagesCollectionViewFlowLayout.h

messageBubbleLeftRightMargin

@property (assign, nonatomic) CGFloat messageBubbleLeftRightMargin
Discussion

The horizontal spacing used to lay out the messageBubbleContainerView frame within each JSQMessagesCollectionViewCell. This container view holds the message bubble image and message contents of a cell.

This value specifies the horizontal spacing between the messageBubbleContainerView and the edge of the collection view cell in which it is displayed. That is, the edge that is opposite the avatar image.

The default value is 40.0f on iPhone and 240.0f on iPad. This value must be positive. For outgoing messages, this value specifies the amount of spacing from the left most edge of the collectionView to the left most edge of a message bubble within a cell.

For incoming messages, this value specifies the amount of spacing from the right most edge of the collectionView to the right most edge of a message bubble within a cell.

Warning: This value may not be exact when the layout object finishes laying out its items, due to the constraints it must satisfy. This value should be considered more of a recommendation or suggestion to the layout, not an exact value.

Declared In

JSQMessagesCollectionViewFlowLayout.h

messageBubbleTextViewFrameInsets

@property (assign, nonatomic) UIEdgeInsets messageBubbleTextViewFrameInsets
Discussion

The inset of the frame of the text view within the messageBubbleContainerView of each JSQMessagesCollectionViewCell. The inset values should be positive and are applied in the following ways:

  1. The right value insets the text view frame on the side adjacent to the avatar image (or where the avatar would normally appear). For outgoing messages this is the right side, for incoming messages this is the left side.

  2. The left value insets the text view frame on the side opposite the avatar image (or where the avatar would normally appear). For outgoing messages this is the left side, for incoming messages this is the right side.

  3. The top value insets the top of the frame.

  4. The bottom value insets the bottom of the frame.

The default value is {0.0f, 0.0f, 0.0f, 6.0f}.

Warning: Adjusting this value is an advanced endeavour and not recommended. You will only need to adjust this value should you choose to provide your own bubble image assets. Changing this value may also require you to manually calculate the itemSize for each cell in the layout by overriding the delegate method collectionView:layout:sizeForItemAtIndexPath:

Declared In

JSQMessagesCollectionViewFlowLayout.h

messageBubbleTextViewTextContainerInsets

@property (assign, nonatomic) UIEdgeInsets messageBubbleTextViewTextContainerInsets
Discussion

The inset of the text container’s layout area within the text view’s content area in each JSQMessagesCollectionViewCell. The specified inset values should be positive.

The default value is {7.0f, 14.0f, 7.0f, 14.0f}.

Warning: Adjusting this value is an advanced endeavour and not recommended. You will only need to adjust this value should you choose to provide your own bubble image assets. Changing this value may also require you to manually calculate the itemSize for each cell in the layout by overriding the delegate method collectionView:layout:sizeForItemAtIndexPath:

Declared In

JSQMessagesCollectionViewFlowLayout.h

outgoingAvatarViewSize

@property (assign, nonatomic) CGSize outgoingAvatarViewSize
Discussion

The size of the avatar image view for outgoing messages.

The default value is (30.0f, 30.0f). Set to CGSizeZero to remove outgoing avatars. You may use kJSQMessagesCollectionViewAvatarSizeDefault to size your avatars to the default value.

Declared In

JSQMessagesCollectionViewFlowLayout.h

springResistanceFactor

@property (assign, nonatomic) NSUInteger springResistanceFactor
Discussion

Specifies the degree of resistence for the “springiness” of items in the layout. This property has no effect if springinessEnabled is set to NO.

The default value is 1000. Increasing this value increases the resistance, that is, items become less “bouncy”. Decrease this value in order to make items more “bouncy”.

Declared In

JSQMessagesCollectionViewFlowLayout.h

springinessEnabled

@property (assign, nonatomic) BOOL springinessEnabled
Discussion

Specifies whether or not the layout should enable spring behavior dynamics for its items using UIDynamics.

The default value is NO, which disables “springy” or “bouncy” items in the layout. Set to YES if you want items to have spring behavior dynamics. You must set this property from viewDidAppear: in your JSQMessagesViewController subclass.

Warning: Though this feature is mostly stable, it is still considered an experimental feature.

Declared In

JSQMessagesCollectionViewFlowLayout.h

Instance Methods

messageBubbleSizeForItemAtIndexPath:

- (CGSize)messageBubbleSizeForItemAtIndexPath:(NSIndexPath *)indexPath
Discussion

Computes and returns the size of the messageBubbleImageView property of a JSQMessagesCollectionViewCell at the specified indexPath. The returned size contains the required dimensions to display the entire message contents. Note, this is not the entire cell, but only its message bubble.

Parameters

indexPath

The index path of the item to be displayed.

Return Value

The size of the message bubble for the item displayed at indexPath.

Declared In

JSQMessagesCollectionViewFlowLayout.h

sizeForItemAtIndexPath:

- (CGSize)sizeForItemAtIndexPath:(NSIndexPath *)indexPath
Discussion

Computes and returns the size of the item specified by indexPath.

Parameters

indexPath

The index path of the item to be displayed.

Return Value

The size of the item displayed at indexPath.

Declared In

JSQMessagesCollectionViewFlowLayout.h