Group Group Group Group Group Group Group Group Group Forums

UIStackView Tutorial: Introducing Stack Views

Learn how to simplify your iOS layouts in iOS 11 with this UIStackView tutorial.

This is a companion discussion topic for the original entry at

Some thing is really strange, seance when is the hidden property animatable?

Hi, I am just in the second part where you need to select the Rating label and the 5 star label. As soon as I select embed in Stack View, the width of both go to zero. I tried to do the remainder of that section and it ends up with the stack way at the top of the screen.

I am using Xcode 9 beta 4.


1 Like


I have a general question concerning tutorials like this one.

Would it possible to create a PDF-file of these tutorials, so that you can download and also print them out?

Sometimes it much better if you could print out these tutorials, especially if you want to work with them.

I know it’s a question for Ray but perhaps other readers would appreciate this suggestion as well. :smiley:



can’t run this project. i got this error:
.../VacationSpots_Starter/VacationSpots/AppDelegate.swift:56:57: Type 'NSAttributedString' has no member 'foregroundColor'

Hi @vizel, this tutorial was written for Xcode 9, Swift 4 and the iOS 11 SDK and I think that you’re trying to open it in Xcode 8? You can download Xcode 9 from here:

Hey @rapier64, thanks for the suggestion! :slightly_smiling_face:

Most of our books already cover (or will do in the future) these subjects in slightly other ways so spending extra time making PDF copies isn’t usually worth the effort. Saying that though, you could always “print” the page and then save it out to a PDF yourself? Hope that helps :+1:

Hi @arkadi, this has been possible ever since UIStackView was introduced in iOS 9 however it only applies to views that have been embedded as an arranged subview of a stack view.

This is because internally a 0pt height constraint is applied to the subview when hiding and this is something that has always been animatable. You can read more about this in the Dynamically Changing the Stack View’s Content section of the UIStackView docs

I have exactly the same problem.

I’m get same problem, using Xcode 9 beta 4, on the starter project.
The compiler fix suggestion says
Cannot convert value of type ‘String’ to expected dictionary key type ‘NSAttributedStringKey’
Replace ‘NSAttributedStringKey.foregroundColor.rawValue’ with ‘NSAttributedStringKey(rawValue: NSAttributedStringKey.foregroundColor.rawValue)’

After applying fix, the project runs.

Have a nice day !

1 Like

I set the “Preferred width” of both the Rating label and 5 star label to 100 (in the Size Inspector), and the problem is gone. It works, but I have no idea why it works :confused:


Yes, I had the same result as @nilocski using Xcode 9 beta 4. And the Xcode recommended fix should get you going. Click the Fix button:

We’ll update the starter project, so this won’t be a problem for much longer.

Kevin Colligan

Hi @pegasusroe @jeffkempster: I’m seeing the same thing since updating to Xcode 9 beta 4 (this worked fine in beta 3.)

It appears to be a bug. For some reason, the when adding the top constraint for the Rating stack view, Xcode adds it to the base View rather than the label just above it. You can see that by clicking the little down arrow by the top constraint:

Like @pegasusroe discovered, you can get around this by adding a width to the stack view. Step-by-step, you would (1) select the stack view, (2) click on the Pin button, (3) add a Width of 200 (or whatever) and click “Add 1 Constraint”, (4) click on the Pin button again and continue with the tutorial – make sure the top constraint you add is 20 from the whatToSee label:


1 Like

Same Here, I used the preferred width as mention and it worked. But wondering why

I am not getting the squished “Submit Rating” in my iPhone SE simulator with iOS 11/10.3. It looks ok.
Using XCode 9 GM release

I found out that problem about stacking RATING and ★★★★★.

If you change the Lines property from 0 to 1 in the ★★★★★ label, then the stack view can be created without problem.

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]