ClipLayout 1.3.2

ClipLayout 1.3.2

Maintained by DenisLitvin.



  • By
  • Denis Litvin

ClipLayout

Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

ClipLayout is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ClipLayout'

💫 Expressiveness

It's easy to read and takes only few lines of code to make complex layout.

🚀 Performance

It's the fastest Layout Engine compared to other popular libraries.

📐 Automatic estimations

You don't have to specify the size. ClipLayout will try to estimate how much space the view needs for it's content. And place subview in the center of the superview by default.

✂️ Trimming

If views don't fit on the screen their size will be adjusted.

Animations out of the box

It's easy to animate changes in Clip Layout. Just alter the layout however you want and call clip.invalidateLayout() on the superview in animation context.

view.clip.withDistribution(flag ? .column : .row)
UIView.animate(withDuration: 0.8) {
    self.superview.clip.invalidateLayout()
}

🙋‍♂️ RTL language support

RTL support is enabled by default on any view. If you use distribution == .row, views will be mirrored in horizontal axis. To disable RTL set supportRightToLeft = false.

🍻 Interoperability

You can mix and match ClipLayout with Auto Layout or any other framework. You only need to specify property on UIView enable = true on parent and descendant views that use Clip Layout.

🎛 Dynamic Collection Cells

You set up the Cell that conforms to DataBinder and inherits ClipCell

class DynamicCell: ClipCell, DataBinder {
  func set(data: SomeData) {
  }
 }

Then you just use ClipCollectionView with your cell as a generic parameter and everything will be automaticaly handled. You can optionaly set maxSize to restrict cell to some size, it defaults to CollectionView width and unlimited height. To set data use data property.

let view = ClipCollectionView<DynamicCell>(collectionViewLayout: UICollectionViewFlowLayout())
view.data = [SomeData]()

🎏 Objc and Swift APIs

In swift you can use both.

objc:

[view configureWithBlock:^(ClipLayout *clip) {
        clip.wantsSize = CGSizeMake(100, 100);
        clip.alignment.vertical = ClipAlignmentHead;
        clip.distribution = ClipDistributionRow;
    }];

swift:

view.clip.enabled().withWidth(100).withHeight(100).verticallyAligned(.head).withDistribution(.row)

🔲 CALayer support

Author

Denis Litvin, [email protected]

License

ClipLayout is available under the MIT license. See the LICENSE file for more info.