Hacker News new | ask | show | jobs
by Klonoar 2778 days ago
Sometimes I feel like the only one who's totally fine with AutoLayout as-is. IMO it is hands-down the most straightforward and easy to understand way of constructing UI, and I've dealt with an insane number of UI toolkits over the years.

Furthermore, anytime I see someone complaining about it and I check out their solution with AL... they've overcomplicated how they're setting constraints and doing the layout, and it ends up usually being the issue more than AL itself.

3 comments

> Sometimes I feel like the only one who's totally fine with AutoLayout as-is.

Agreed. It took me a while to find some idioms I like, but once I did that I like it quite a bit more than what I was doing in HTML land (note: not a webdev). It probably helps in my case that this is a solo project so I had the freedom to try a bunch of different styles until I found one I like.

I find the bad part is how user events are handled, particularly when multiple parts of the UI need to be changed. This, like autolayout, could be an issue of inexperience.

Same. Especially now that we have NSLayoutAnchor. Sure, it wasn't ideal when VFL was more widely used, but these days it works great and is as readable as any DSL I've seen.
Agreed. About the only thing I do on top of it is add some operators for setting up AutoLayout, so I can write code like

  NSLayoutConstraint.activate([
      label.topAnchor ≈ view.topAnchor,
      label.leadingAnchor ≈ view.leadingAnchor + 8,
      label.centerXAnchor ≈ view.centerXAnchor,
      view.bottomAnchor ≥ label.bottomAnchor
  ])