Comments (8)
Also, if you're using baseline to baseline vertical constraints (i.e. Line spacing), the system spacing will take font size into account.
from anchorage.
from anchorage.
from anchorage.
If you use the system spacing on a vertical constraint from baseline to baseline of two labels, that spacing will dynamically adjust based on Dynamic Type size.
from anchorage.
Oops, I posted the "before" screenshot. Here's "After". It's from "What's New in Cocoa Touch" from WWDC 2017.
from anchorage.
Here's a little more info. The constraintEqualToSystemSpacing
method isn't in the API diffs as of this writing, but here it is from the generated Swift header:
extension NSLayoutYAxisAnchor {
/* Constraints of the form,
receiver [= | ≥ | ≤] 'anchor' + 'multiplier' * system space,
where the value of the system space is determined from information available from the anchors.
The constraint affects how far the receiver will be positioned below 'anchor'.
If either the receiver or 'anchor' is the firstBaselineAnchor or lastBaselineAnchor of a view with text content
then the spacing will depend on the fonts involved and will change when those do.
*/
@available(iOS 11.0, *)
open func constraintEqualToSystemSpacingBelow(_ anchor: NSLayoutYAxisAnchor, multiplier: CGFloat) -> NSLayoutConstraint
@available(iOS 11.0, *)
open func constraintGreaterThanOrEqualToSystemSpacingBelow(_ anchor: NSLayoutYAxisAnchor, multiplier: CGFloat) -> NSLayoutConstraint
@available(iOS 11.0, *)
open func constraintLessThanOrEqualToSystemSpacingBelow(_ anchor: NSLayoutYAxisAnchor, multiplier: CGFloat) -> NSLayoutConstraint
}
I believe the doc comment has swapped the 'multiplier'
and system space
values, but otherwise it gives a sense of how the API is used. I'm thinking that Anchorage may need some under-the-hood changes so that it can dynamically pick which methods to use based on the equation, but I think it will be possible.
Also, note that this is possible only on the Y axis, since it's apparently only used with text line spacing. Can our expression system encode that limitation?
from anchorage.
Oops, I think I was wrong about y-axis-only. According to these generated diffs, there are x and y variants of the system spacing methods:
Added -[NSLayoutXAxisAnchor anchorWithOffsetToAnchor:]
Added NSLayoutXAxisAnchor (UIViewDynamicSystemSpacingSupport)
Added -[NSLayoutXAxisAnchor constraintEqualToSystemSpacingAfterAnchor:multiplier:]
Added -[NSLayoutXAxisAnchor constraintGreaterThanOrEqualToSystemSpacingAfterAnchor:multiplier:]
Added -[NSLayoutXAxisAnchor constraintLessThanOrEqualToSystemSpacingAfterAnchor:multiplier:]
Added -[NSLayoutYAxisAnchor anchorWithOffsetToAnchor:]
Added NSLayoutYAxisAnchor (UIViewDynamicSystemSpacingSupport)
Added -[NSLayoutYAxisAnchor constraintEqualToSystemSpacingBelowAnchor:multiplier:]
Added -[NSLayoutYAxisAnchor constraintGreaterThanOrEqualToSystemSpacingBelowAnchor:multiplier:]
Added -[NSLayoutYAxisAnchor constraintLessThanOrEqualToSystemSpacingBelowAnchor:multiplier:]
from anchorage.
Interesting that this is the first time a multiplier is supported for a spacing constraint. Do we know if a multiplier version of all spacing constraints will be available in iOS 11, or just this one?
from anchorage.
Related Issues (20)
- Prevent duplicate constraints. HOT 5
- Manual installation instructions HOT 2
- Relative alignment samples outdated HOT 2
- View could not display in full-screen size, black gap on top and also at bottom HOT 2
- Priority documentation not matching reality HOT 4
- Use of `BinaryFloatingPoint` types with custom operators. HOT 7
- Constructing an `AnchorPair` outside of Anchorage will be impossible HOT 4
- Multi-binding syntax
- EXC_BAD_ACCESS switching from 4.0.0 to 4.1.0+ HOT 4
- Carthage prebuilt framework
- Order of operation when creating constraint HOT 5
- Update for Swift 5.0 HOT 4
- Add a shorthand for accessibilityIdentifier HOT 1
- Mark invalid combinations of anchors as deprecated HOT 1
- First time anchorage-usage confusing HOT 1
- Remove convenience accessors on UIViewController subclasses HOT 2
- Type-checking Performance HOT 10
- Add a logo
- Please Update for Swift 5.2 HOT 2
- Carthage problems on Xcode 12 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anchorage.