Skip to content

Commit

Permalink
Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Nikita Ermolenko committed Feb 2, 2018
1 parent 16aac10 commit 7bd6ec4
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,31 @@ label.configureFrame { maker in

## Container

Use this method when you want to set `width` and `height` by wrapping all subviews.
Use this method when you want to calculate a `width` and `height` by wrapping all subviews.

You can also specify a special container relation:

```swift
public enum ContainerRelation {
case width(Number)
case height(Number)
case horizontal(left: Number, right: Number)
case vertical(top: Number, bottom: Number)
}
```

For instance, if you set a width for a container, only a dynamic height will be calculated.

### NOTE:

**It atomatically adds all subviews to the container. Don't add subviews manually.**

**Also important to understand, that it's not correct to call 'left' and 'right' relations together by subview, because `container` sets width relatively width of subview and here is some ambiguous.**
**If you don't use a static width for instance, important to understand, that it's not correct to call `left` and `right` relations together by subviews, because `container` sets width relatively width of subviews and here is some ambiguous.**

![](img/container.png)

```swift
let container = [content1, content2, content3, content4].container(in: view) {
let container = [content1, content2, content3, content4].container(in: view, relation: /* if needed */) {
content1.configureFrame { maker in
maker.centerX()
maker.top()
Expand Down Expand Up @@ -265,6 +278,14 @@ container.configureFrame { maker in
}
```

If you have already configured container, then this method will be more convenient for you:

```swift
[content1, label1, label2, label3].configure(container: container, relation: .horizontal(left: 20, right: 20)) {
// do configuration
}
```

## Cool things:

Sometimes you want to configure a few views with the same size, for examlple. There is a convinience method:
Expand Down

0 comments on commit 7bd6ec4

Please sign in to comment.