Repository navigation
New method sizeToFit(:FitType) & fitSize() is now deprecated - #101
Merged
Merged
Conversation
added 6 commits
November 15, 2017 19:31
… fitSizeHard()
* **`fitWidth()`**
The method **adjust the view's height** based on either the **current view's width** or the **width determined by PinLayout**. The method compute the height based on the result of the view's `sizeThatFits(: CGSize)` method.
Notes:
* The resulting width will never be bigger than the reference width, but could be smaller.
* The resulting size will always respect minWidth/maxWidth/minHeight/maxHeight.
* If margin rules applies, margins will be applied when determining the reference width.
* **`fitWidthHard()`**
Similar to `fitWidth()`, except that the resulting width will **always match the reference width**.
* **`fitHeight()`**
The method **adjust the view's width** based on either the **current view's height** or the **height determined by PinLayout**. The method compute the width based on the result of the view's `sizeThatFits(: CGSize)` method.
Notes:
* The resulting height will always match the reference height.
* The resulting size will always respect minWidth/maxWidth/minHeight/maxHeight.
* If margin rules applies, margins will be applied when determining the reference height.
* **`fitHeightHard()`**
Similar to `fitHeight()`, except that the resulting height will **always match the reference width**.
* **`fitSize()`**
The method **adjust the view's width and height** based on either the **pinned height** or **pinned width**. The method compute the width and height based on the result of the view's `sizeThatFits(: CGSize)` method.
If the **width** has been pinned => the method **adjust the view's height** based on this width.
If the **height** has been pinned => the method **adjust the view's width** based on this height.
If the **width and the height** have been pinned => the method **adjust the view's size** based on both values.
Notes:
* The resulting width/height will never be bigger than the pinnded width/height, but could be smaller.
* The resulting size will always respect minWidth/maxWidth/minHeight/maxHeight.
* If margin rules applies, margins will be applied when determining the reference width/height.
* **`fitSizeHard()`**
Similar to `fitSize()`, except that the resulting width/height will **always match the pinned width/height**..
* `fitSize()` is now deprecated. The new `sizeToFit(:FitType)` should be used instead.
**`sizeToFit(_ fitType: FitType)`**
The method adjust the view's size based on the view's `sizeThatFits()` method result.
PinLayout will adjust either the view's width or height based on the `fitType` parameter value.
Notes:
* If margin rules apply, margins will be applied when determining the reference dimension (width/height).
* The resulting size will always respect `minWidth` / `maxWidth` / `minHeight` / `maxHeight`.
- Parameter fitType: Identify the reference dimension (width / height) that will be used
to adjust the view's size:
.width: The method adjust the view's size based on the **reference width**.
* If properties related to the width have been pinned (e.g: width, left & right, margins, ...),
the **reference width will be determined by these properties**, else the **current view's width**
will be used.
* The resulting width will always **match the reference width**.
.height: The method adjust the view's size based on the **reference height**.
* If properties related to the height have been pinned (e.g: height, top & bottom, margins, ...),
the **reference height will be determined by these properties**, else the **current view's height**
will be used.
* The resulting height will always **match the reference height**.
.widthFlexible: Similar to `.width`, except that PinLayout won't constrain the resulting width to
match the reference width. The resulting width may be smaller of bigger depending on the view's
sizeThatFits(..) method result. For example a single line UILabel may returns a smaller width if its
string is smaller than the reference width.
.heightFlexible: Similar to `.height`, except that PinLayout won't constrain the resulting height to
match the reference height. The resulting height may be smaller of bigger depending on the view's
sizeThatFits(..) method result.
Examples:
```
// Adjust the view's size based on a width of 100 pixels.
// The resulting width will always match the pinned property `width(100)`.
view.pin.width(100).sizeToFit(.width)
// Adjust the view's size based on view's current width.
// The resulting width will always match the view's original width.
// The resulting height will never be bigger than the specified `maxHeight`.
view.pin.sizeToFit(.width).maxHeight(100)
// Adjust the view's size based on 100% of the superview's height.
// The resulting height will always match the pinned property `height(100%)`.
view.pin.height(100%).sizeToFit(.height)
// Adjust the view's size based on view's current height.
// The resulting width will always match the view's original height.
view.pin.sizeToFit(.height)
// Since `.widthFlexible` has been specified, its possible that the resulting
// width will be smaller or bigger than 100 pixels, based of the label's sizeThatFits()
// method result.
label.pin.width(100).sizeToFit(.widthFlexible)
```
Codecov Report
@@ Coverage Diff @@
## master #101 +/- ##
==========================================
+ Coverage 89.51% 89.96% +0.44%
==========================================
Files 31 30 -1
Lines 5810 6067 +257
==========================================
+ Hits 5201 5458 +257
Misses 609 609
Continue to review full report at Codecov.
|
added 2 commits
November 19, 2017 18:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes:
fitSize()is now deprecated. The newsizeToFit(:FitType)should be used instead.New method
sizeToFit(_ fitType: FitType)The method adjust the view's size based on the view's
sizeThatFits()method result.PinLayout will adjust either the view's width or height based on the
fitTypeparameter value.Notes:
minWidth/maxWidth/minHeight/maxHeight.Parameter
fitType: Identify the reference dimension (width / height) that will be usedto adjust the view's size:
.width: The method adjust the view's size based on the reference width.
* If properties related to the width have been pinned (e.g: width, left & right, margins, ...),
the reference width will be determined by these properties, else the current view's width
will be used.
* The resulting width will always match the reference width.
.height: The method adjust the view's size based on the reference height.
* If properties related to the height have been pinned (e.g: height, top & bottom, margins, ...),
the reference height will be determined by these properties, else the current view's height
will be used.
* The resulting height will always match the reference height.
.widthFlexible: Similar to
.width, except that PinLayout won't constrain the resulting width tomatch the reference width. The resulting width may be smaller of bigger depending on the view's
sizeThatFits(..) method result. For example a single line UILabel may returns a smaller width if its
string is smaller than the reference width.
.heightFlexible: Similar to
.height, except that PinLayout won't constrain the resulting height tomatch the reference height. The resulting height may be smaller of bigger depending on the view's
sizeThatFits(..) method result.
Examples: