From 3dad86b3ea06ebc92d62079335bbcc1c0d74a71d Mon Sep 17 00:00:00 2001 From: nixzhu Date: Mon, 7 Sep 2015 14:42:33 +0800 Subject: [PATCH] frame layout of ChatRightImageCell --- .../ChatRightImage/ChatRightImageCell.swift | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/Yep/Views/Cells/ChatRightImage/ChatRightImageCell.swift b/Yep/Views/Cells/ChatRightImage/ChatRightImageCell.swift index 4834efb4..d347b0cb 100644 --- a/Yep/Views/Cells/ChatRightImage/ChatRightImageCell.swift +++ b/Yep/Views/Cells/ChatRightImage/ChatRightImageCell.swift @@ -16,10 +16,23 @@ class ChatRightImageCell: ChatRightBaseCell { typealias MediaTapAction = () -> Void var mediaTapAction: MediaTapAction? - + + 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.yellowColor() + + makeUI() + messageImageView.tintColor = UIColor.rightBubbleTintColor() messageImageView.userInteractionEnabled = true @@ -87,6 +100,15 @@ class ChatRightImageCell: ChatRightBaseCell { if aspectRatio >= 1 { // messageImageViewWidthConstrint.constant = messageImagePreferredWidth + let width = messageImagePreferredWidth + + messageImageView.frame = CGRect(x: CGRectGetMinX(avatarImageView.frame) - 5 - width, y: 0, width: width, height: bounds.height) + + dotImageView.center = CGPoint(x: CGRectGetMinX(messageImageView.frame) - 5, y: CGRectGetMidY(messageImageView.frame)) + + println(dotImageView.frame) + + ImageCache.sharedInstance.imageOfMessage(message, withSize: CGSize(width: messageImagePreferredWidth, height: ceil(messageImagePreferredWidth / aspectRatio)), tailDirection: .Right, completion: { [weak self] progress, image in dispatch_async(dispatch_get_main_queue()) { @@ -99,6 +121,13 @@ class ChatRightImageCell: ChatRightBaseCell { } else { // messageImageViewWidthConstrint.constant = messageImagePreferredHeight * aspectRatio + let width = messageImagePreferredHeight * aspectRatio + messageImageView.frame = CGRect(x: CGRectGetMinX(avatarImageView.frame) - 5 - width, y: 0, width: width, height: bounds.height) + + dotImageView.center = CGPoint(x: CGRectGetMinX(messageImageView.frame) - 5, y: CGRectGetMidY(messageImageView.frame)) + + println(dotImageView.frame) + ImageCache.sharedInstance.imageOfMessage(message, withSize: CGSize(width: messageImagePreferredHeight * aspectRatio, height: messageImagePreferredHeight), tailDirection: .Right, completion: { [weak self] progress, image in dispatch_async(dispatch_get_main_queue()) { @@ -112,6 +141,14 @@ class ChatRightImageCell: ChatRightBaseCell { } else { // messageImageViewWidthConstrint.constant = messageImagePreferredWidth + let width = messageImagePreferredWidth + + messageImageView.frame = CGRect(x: CGRectGetMinX(avatarImageView.frame) - 5 - width, y: 0, width: width, height: bounds.height) + + dotImageView.center = CGPoint(x: CGRectGetMinX(messageImageView.frame) - 5, y: CGRectGetMidY(messageImageView.frame)) + + println(dotImageView.frame) + ImageCache.sharedInstance.imageOfMessage(message, withSize: CGSize(width: messageImagePreferredWidth, height: ceil(messageImagePreferredWidth / messageImagePreferredAspectRatio)), tailDirection: .Right, completion: { [weak self] progress, image in dispatch_async(dispatch_get_main_queue()) {