JSQMessagesCollectionViewFlowLayout.m
を下記のように修正
Objective
1- (void)jsq_adjustSpringBehavior:(UIAttachmentBehavior *)springBehavior forTouchLocation:(CGPoint)touchLocation
2{
3 UICollectionViewLayoutAttributes *item = (UICollectionViewLayoutAttributes *)[springBehavior.items firstObject];
4 CGPoint center = item.center;
5
6 // if touch is not (0,0) -- adjust item center "in flight"
7 if (!CGPointEqualToPoint(CGPointZero, touchLocation)) {
8 CGFloat distanceFromTouch = fabs(touchLocation.y - springBehavior.anchorPoint.y);
9 CGFloat scrollResistance = distanceFromTouch / self.springResistanceFactor;
10
11 if (self.latestDelta < 0.0f) {
12 //ここを修正start
13 //center.y += MAX(self.latestDelta, self.latestDelta * scrollResistance)
14 center.y = 0;
15 //ここを修正end
16
17 }
18 else {
19 //ここを修正start
20 //center.y += MIN(self.latestDelta, self.latestDelta * scrollResistance);
21 center.y = 0;
22 //ここを修正end
23 }
24 item.center = center;
25 }
26}
JSQMessagesViewController
クラスをオーバーライドしたクラスに下記を追加
swift
1 // ナビゲーションバーの高さを取得
2 let navBarHeight = self.navigationController?.navigationBar.frame.size.height
3 // ステータスバーの高さを取得
4 let statusHeight = UIApplication.shared.statusBarFrame.height
5
6 topContentAdditionalInset = topContentAdditionalInset - navBarHeight! - statusHeight
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。