LuxChat  2.0
Instant messenger for iOS
Instance Methods | Properties | List of all members
JSQMessagesCollectionViewFlowLayout Class Reference

#import <JSQMessagesCollectionViewFlowLayout.h>

Inheritance diagram for JSQMessagesCollectionViewFlowLayout:

Instance Methods

(CGSize) - messageBubbleSizeForItemAtIndexPath:
 
(CGSize) - sizeForItemAtIndexPath:
 

Properties

JSQMessagesCollectionViewcollectionView
 
BOOL springinessEnabled
 
NSUInteger springResistanceFactor
 
CGFloat itemWidth
 
UIFont * messageBubbleFont
 
CGFloat messageBubbleLeftRightMargin
 
UIEdgeInsets messageBubbleTextViewFrameInsets
 
UIEdgeInsets messageBubbleTextViewTextContainerInsets
 
CGSize incomingAvatarViewSize
 
CGSize outgoingAvatarViewSize
 
NSUInteger cacheLimit
 

Detailed Description

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.

See also
JSQMessagesCollectionViewDelegateFlowLayout.
JSQMessagesCollectionViewCell.

Method Documentation

- (CGSize) messageBubbleSizeForItemAtIndexPath: (NSIndexPath *)  indexPath

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
indexPathThe index path of the item to be displayed.
Returns
The size of the message bubble for the item displayed at indexPath.
- (CGSize) sizeForItemAtIndexPath: (NSIndexPath *)  indexPath

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

Parameters
indexPathThe index path of the item to be displayed.
Returns
The size of the item displayed at indexPath.

Property Documentation

- (NSUInteger) cacheLimit
readwritenonatomicassign

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.

- (JSQMessagesCollectionView*) collectionView
readnonatomicassign

The collection view object currently using this layout object.

- (CGSize) incomingAvatarViewSize
readwritenonatomicassign

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.

- (CGFloat) itemWidth
readnonatomicassign

Returns the width of items in the layout.

- (UIFont*) messageBubbleFont
readwritenonatomicstrong

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.

- (CGFloat) messageBubbleLeftRightMargin
readwritenonatomicassign

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.
See also
JSQMessagesCollectionViewCellIncoming.
JSQMessagesCollectionViewCellOutgoing.
- (UIEdgeInsets) messageBubbleTextViewFrameInsets
readwritenonatomicassign

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:
- (UIEdgeInsets) messageBubbleTextViewTextContainerInsets
readwritenonatomicassign

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:
- (CGSize) outgoingAvatarViewSize
readwritenonatomicassign

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.

- (BOOL) springinessEnabled
readwritenonatomicassign

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.
- (NSUInteger) springResistanceFactor
readwritenonatomicassign

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".


The documentation for this class was generated from the following files: