向JSQMessage单元格添加自定义按钮

时间:2018-01-24 07:43:57

标签: ios swift chat jsqmessagesviewcontroller

  

我必须构建一个与下面相同的用户界面

enter image description here

  

我成功开发的UI是

enter image description here

  

我开发的UI正在使用所有现有的控件和类,i   没有为此UI定制任何单元格。

     

现在我很难添加一个最多出现计数的DIMOND按钮   左侧(收到的消息)。

     

无论如何,我可以通过编程方式添加此按钮和标签   没有自定义完整的单元格。

 override func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {

        let message = messageList[indexPath.item]
            let cell = super.collectionView(collectionView, cellForItemAt: indexPath) as! JSQMessagesCollectionViewCell
            cell.textView?.textColor = UIColor.black
            if message.senderId != strMemberID {
                // configure avatar
                cell.avatarImageView.isHidden = false
                cell.avatarImageView.layer.cornerRadius = CGFloat(avatarImageDiameter/2)
                cell.avatarImageView.clipsToBounds = true

                let profilePictureURL = "\(quickChatUserProfilePictureBaseUrl)/\(message.senderId!)_m.jpg"

                cell.avatarImageView.sd_setImage(with: URL(string: profilePictureURL), placeholderImage: UIImage(named: kIndividualChatICon))
            } else {
                // add gesture only for group chat and on sender chat bubbles
            }
            if (message.messageType == MessageType.TextMessage.rawValue) {
                 cell.textView.attributedText = getAttributedMessageText(message: message)
            } else if (message.messageType == MessageType.NotificationMessage.rawValue) {
                cell.avatarImageView.isHidden = true
            }
           cell.textView?.linkTextAttributes = [NSForegroundColorAttributeName : QuickchatTheme.getHyperLinksColorForChatBubbles()]
            return cell
    }

0 个答案:

没有答案
相关问题