Skip to content

Commit 85ff4c1

Browse files
author
Baris Sencan
committed
Document UIView methods
Also removed old API methods.
1 parent 19cd733 commit 85ff4c1

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

README.md

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ Just `import ManualLayout` in your code and use the methods and properties provi
4141

4242
#API Cheat Sheet
4343

44+
###Smart Assign Operator
45+
46+
The smart assign operator `=~` has only one job; to make your life easier.
47+
48+
```swift
49+
someView.origin =~ (0, 20)
50+
anotherView.size =~ (100, 100)
51+
yetAnotherView.frame =~ (0, 120, view.width, 100)
52+
```
53+
4454
###CALayer/UIView Properties
4555

4656
```swift
@@ -72,6 +82,24 @@ The difference between alternate edges and normal edges require a bit of explain
7282

7383
So basically, *setting a normal edge's position drags the whole view along with that edge but setting an alternative edge's position drags just that edge*. And don't worry if you, for example, try to drag a left edge past its view's right edge. Edge swapping is done automatically so you don't have to worry about.
7484

85+
###UIView Methods
86+
87+
Just one method with two variants for now, and those are used for easy size calculations.
88+
89+
```swift
90+
func sizeToFit(width: CGFloat, height: CGFloat) -> CGSize
91+
func sizeToFit(constrainedSize: CGSize) -> CGSize
92+
```
93+
94+
So let's say that you have a label inside a view and you want to lay it out with an inset of 4 points on all sides, you could easily do the following:
95+
96+
```swift
97+
myLabel.sizeToFit(inset(myView, 4))
98+
myLabel.origin =~ (4, 4)
99+
```
100+
101+
Done!
102+
75103
###UIViewController Properties
76104

77105
```swift
@@ -108,33 +136,3 @@ func offset(rect: CGRect, dx: CGFloat, dy: CGFloat) -> CGRect
108136
```
109137

110138
These functions never modify the view/layer/rectangle they are passed.
111-
112-
###Smart Assign Operator
113-
114-
The smart assign operator `=~` has only one job; to make your life easier.
115-
116-
```swift
117-
someView.origin =~ (0, 20)
118-
anotherView.size =~ (100, 100)
119-
yetAnotherView.frame =~ (0, 120, view.width, 100)
120-
```
121-
122-
###CALayer/UIView Methods
123-
124-
Replace the word "layer" with "view" for the UIView methods.
125-
126-
```swift
127-
func centerInSuperlayer()
128-
func centerDimensionInSuperlayer(dimension: ManualLayoutDimension) // .X or .Y
129-
```
130-
131-
More coming soon.
132-
133-
###ManualLayout Methods
134-
135-
```swift
136-
static func getOriginForCenteringRect(rect: CGRect, inRect container: CGRect) -> CGPoint
137-
static func getPositionForCenteringRect(rect: CGRect, dimension: ManualLayoutDimension, inRect container: CGRect) -> CGFloat
138-
```
139-
140-
More coming soon.

0 commit comments

Comments
 (0)