Giter VIP home page Giter VIP logo

Comments (8)

ZevEisenberg avatar ZevEisenberg commented on May 14, 2024

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.

ZevEisenberg avatar ZevEisenberg commented on May 14, 2024

img_1502

from anchorage.

mr-fixit avatar mr-fixit commented on May 14, 2024

from anchorage.

ZevEisenberg avatar ZevEisenberg commented on May 14, 2024

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.

ZevEisenberg avatar ZevEisenberg commented on May 14, 2024

Oops, I posted the "before" screenshot. Here's "After". It's from "What's New in Cocoa Touch" from WWDC 2017.
screen shot 2017-06-11 at 12 07 31 pm

from anchorage.

ZevEisenberg avatar ZevEisenberg commented on May 14, 2024

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.

ZevEisenberg avatar ZevEisenberg commented on May 14, 2024

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.

jvisenti avatar jvisenti commented on May 14, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.