CocoaPods trunk is moving to be read-only. Read more on the blog, there are 13 months to go.
| TestsTested | ✗ |
| LangLanguage | Obj-CObjective C |
| License | MIT |
| ReleasedLast Release | Jan 2015 |
Maintained by Anton Bukov.
| Depends on: | |
| JRSwizzle | >= 0 |
| ObjcAssociatedObjectHelpers | >= 0 |
Add UIViewAutoresize support to iOS CALayers and fast UIView to CALayer conversion method
pod 'CALayer-AutoresizingMask'
Not use Autolayout in this storyboard or xib and use autoresizing mask you need.
Hot swap non touchable UIViews with CALayers in IB. Remember it applies recursively to all subviews.
Use your old IBOutlets to views to access visible layers :)
Now all CALayers have property autoresizingMask with type UIVIewAutoresizing. You can use it too!
It just implements simple algorithm:
Increase origin and size of self.frame proportionaly to superviews frame increment divided by number of flexible elements on each axe. That is all!
CGFloat dx = self.superlayer.bounds.size.width - self.superlayerSize.width;
CGFloat dy = self.superlayer.bounds.size.height - self.superlayerSize.height;
dx /= ((mask & UIViewAutoresizingFlexibleLeftMargin)?1:0)
+ ((mask & UIViewAutoresizingFlexibleWidth)?1:0)
+ ((mask & UIViewAutoresizingFlexibleRightMargin)?1:0);
dy /= ((mask & UIViewAutoresizingFlexibleTopMargin)?1:0)
+ ((mask & UIViewAutoresizingFlexibleHeight)?1:0)
+ ((mask & UIViewAutoresizingFlexibleBottomMargin)?1:0);
CGRect frame = self.frame;
frame.origin.x += (mask & UIViewAutoresizingFlexibleLeftMargin)?dx:0;
frame.origin.y += (mask & UIViewAutoresizingFlexibleTopMargin)?dy:0;
frame.size.width += (mask & UIViewAutoresizingFlexibleWidth)?dx:0;
frame.size.height += (mask & UIViewAutoresizingFlexibleHeight)?dy:0;
self.frame = frame;You are welcome to fork, PR, create issues ...