BoundsObserving

public protocol BoundsObserving : AnyObject

Describes an object interested in observing the bounds of a view. Attachment is BoundsObserving and reacts to changes in the bounds of views hosted within the Attachment. Any view contained in the Attachment that is capable of changing its bounds must define and set BoundsObserving to Attachment.

Usage Example

 class MyAttachmentView: UIView {
 weak var boundsObserver: BoundsObserving?

 override var bounds: CGRect {
     didSet {
         guard oldValue != bounds else { return }
         boundsObserver?.didChangeBounds(bounds)
     }
    }
 }

 let myView = MyAttachmentView()
 let attachment = Attachment(myView, size: .matchContent)
 myView.boundsObserver = attachment
  • Lets the observer know that bounds of current object have changed

    Declaration

    Swift

    func didChangeBounds(_ bounds: CGRect, oldBounds: CGRect)

    Parameters

    bounds

    New bounds