-2

I am having a chat app using jsqmessangerViewController everything is working fine but I don't know how to add a date in header and time in chat cell in swift.

Faysal Ahmed
  • 7,501
  • 5
  • 28
  • 50

1 Answers1

0

If you want something like this then i have done the following steps.

Display date at the top label and add a check to match previous one(if current and previous date is same then do not display otherwise display).

let previousMessageObject =
    messageList[indexPath.item-1]
                if (previousMessageObject.messageTime  == currentMessage.messageTime){
                    return CGFloat(kZero)
                }

and for displaying time just append time with message text(use attributed string) and display as simple text. This will serve the purpose

enter image description here

aqsa arshad
  • 801
  • 8
  • 27
  • Could u help me with top label display because I m getting date in every cell I want date on single page of a particular date and then all messages for that day with date swift @aqsa arshad – Dilip Tiwari Aug 01 '18 at 03:32
  • Yes, I would be happy to help. – aqsa arshad Aug 02 '18 at 07:10
  • You need to check that manually for every message. Match 1-1 dates and return height of top label if date is different, otherwise return zero. – aqsa arshad Aug 02 '18 at 07:12