From d2f2e1cb229f62ff7b41fcbfaa21310042c56f39 Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Fri, 29 Jun 2018 12:41:30 -0400 Subject: [PATCH] Respond to CR. --- .../Cells/OWSMessageBubbleView.m | 2 + SignalMessaging/Views/OWSLayerView.swift | 40 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 SignalMessaging/Views/OWSLayerView.swift diff --git a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m index 59f8f1f33..dd4c26ede 100644 --- a/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m +++ b/Signal/src/ViewControllers/ConversationView/Cells/OWSMessageBubbleView.m @@ -896,6 +896,8 @@ NS_ASSUME_NONNULL_BEGIN [wrapper addSubview:downloadView]; [downloadView autoPinWidthToSuperview]; [downloadView autoVCenterInSuperview]; + [downloadView autoPinEdgeToSuperviewMargin:ALEdgeTop relation:NSLayoutRelationGreaterThanOrEqual]; + [downloadView autoPinEdgeToSuperviewMargin:ALEdgeBottom relation:NSLayoutRelationGreaterThanOrEqual]; self.loadCellContentBlock = ^{ // Do nothing. diff --git a/SignalMessaging/Views/OWSLayerView.swift b/SignalMessaging/Views/OWSLayerView.swift new file mode 100644 index 000000000..5ff12aaa1 --- /dev/null +++ b/SignalMessaging/Views/OWSLayerView.swift @@ -0,0 +1,40 @@ +// +// Copyright (c) 2018 Open Whisper Systems. All rights reserved. +// + +import Foundation + +@objc +class OWSLayerView: UIView { + let layoutCallback: ((UIView) -> Void) + + @objc + public required init(frame: CGRect, layoutCallback : @escaping (UIView) -> Void) { + self.layoutCallback = layoutCallback + super.init(frame: frame) + } + + required init?(coder aDecoder: NSCoder) { + self.layoutCallback = { _ in + } + super.init(coder: aDecoder) + } + + override var bounds: CGRect { + didSet { + layoutCallback(self) + } + } + + override var frame: CGRect { + didSet { + layoutCallback(self) + } + } + + override var center: CGPoint { + didSet { + layoutCallback(self) + } + } +}