FrameObserver is a framework that lets you attach observers to any UIView subclass and get notified when its size changes. It doesn’t use any Method Swizzling or KVO so it’ll be perfectly safe to use. It is especially useful when dealing with entities that require you to supply a CGRect to them, e.g CAGradientLayer.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

Then, to add FrameObserver to your project, specify FrameObserver in your Podfile:

<div class="snippet-clipboard-content position-relative" data-snippet-clipboard-copy-content="source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '’ do
pod ‘FrameObserver’
end
“>

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '' do
    pod 'FrameObserver'
end