From c102e42e44b1f2ce2d64d0f99194daf0922bc740 Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 7 Sep 2015 14:24:14 +0800 Subject: [PATCH] frame layout of ChatRightTextCell --- .../ChatRightBase/ChatRightBaseCell.swift | 4 +-- .../ChatRightText/ChatRightTextCell.swift | 31 ++++++++++++++++++- .../Cells/ChatRightText/ChatRightTextCell.xib | 2 +- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/Yep/Views/Cells/ChatRightBase/ChatRightBaseCell.swift b/Yep/Views/Cells/ChatRightBase/ChatRightBaseCell.swift index bcf1cf24..7491c3ee 100644 --- a/Yep/Views/Cells/ChatRightBase/ChatRightBaseCell.swift +++ b/Yep/Views/Cells/ChatRightBase/ChatRightBaseCell.swift @@ -11,8 +11,8 @@ import UIKit class ChatRightBaseCell: ChatBaseCell { @IBOutlet weak var dotImageView: UIImageView! - @IBOutlet weak var gapBetweenDotImageViewAndBubbleConstraint: NSLayoutConstraint! - +// @IBOutlet weak var gapBetweenDotImageViewAndBubbleConstraint: NSLayoutConstraint! + var messageSendState: MessageSendState = .NotSend { didSet { switch messageSendState { diff --git a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift index 2e03880b..2f05643e 100644 --- a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift +++ b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift @@ -26,9 +26,22 @@ class ChatRightTextCell: ChatRightBaseCell { var longPressAction: (() -> Void)? + func makeUI() { + + let fullWidth = UIScreen.mainScreen().bounds.width + + let halfAvatarSize = YepConfig.chatCellAvatarSize() / 2 + + avatarImageView.center = CGPoint(x: fullWidth - halfAvatarSize - YepConfig.chatCellGapBetweenWallAndAvatar(), y: halfAvatarSize) + } + override func awakeFromNib() { super.awakeFromNib() + backgroundColor = UIColor.redColor() + + makeUI() + // avatarImageViewTrailingConstraint.constant = YepConfig.chatCellGapBetweenWallAndAvatar() textContentTextView.textContainer.lineFragmentPadding = 0 @@ -107,7 +120,23 @@ class ChatRightTextCell: ChatRightBaseCell { // textContentTextViewLeadingConstraint.constant = YepConfig.chatTextGapBetweenWallAndContentLabel() - YepConfig.ChatCell.magicWidth // } - contentView.layoutIfNeeded() +// contentView.layoutIfNeeded() + + textContainerView.frame = CGRect(x: CGRectGetMinX(avatarImageView.frame) - YepConfig.chatCellGapBetweenTextContentLabelAndAvatar() - textContentLabelWidth, y: 3, width: textContentLabelWidth, height: bounds.height - 3 * 2) + + println(textContainerView.frame) + + bubbleBodyImageView.frame = CGRectInset(textContainerView.frame, -12, -3) + + println(bubbleBodyImageView.frame) + + bubbleTailImageView.center = CGPoint(x: CGRectGetMaxX(bubbleBodyImageView.frame), y: CGRectGetMidY(avatarImageView.frame)) + + println(bubbleTailImageView.frame) + + dotImageView.center = CGPoint(x: CGRectGetMinX(bubbleBodyImageView.frame) - 5, y: CGRectGetMidY(bubbleBodyImageView.frame)) + + println(dotImageView.frame) if let sender = message.fromFriend { AvatarCache.sharedInstance.roundAvatarOfUser(sender, withRadius: YepConfig.chatCellAvatarSize() * 0.5) { [weak self] roundImage in diff --git a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib index 887092b2..ce2c56bf 100644 --- a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib +++ b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.xib @@ -39,7 +39,7 @@ - +