I started to create a very simple tic-tac-toe game.
The main goal is to make the view proportional to all screen sizes of all iOS devices.
So I put the image on a ViewController
, make it full size of screen and then I put it into a Stack View. I've added constrains to this Stack View 0 to all sides.
And when I ran the simulator then everything looks good. But I receive a message in console panel. What does it mean?

- 1
- 1

- 2,143
- 5
- 17
- 24
-
please show your code :) – Mo Farhand Oct 20 '15 at 14:21
-
there are no code yet. It is a blank project with elements on Main Storyboard. Look at screenshot on the first message – Alex Belke Oct 21 '15 at 04:07
-
4This has appeared since using Xcode 7+. I believe other people view this as an "error" from something Apple has done and nothing you have done, but I can't confirm this. I've submitted apps with this and everything seems to be fine. – Darren Oct 21 '15 at 09:50
4 Answers
It could happen because you changed the Mode attribute of the StackView:
I got this warning when I set Mode to Aspect Fit.

- 2,176
- 1
- 16
- 12
-
4
-
25**How did you figure this out?** the warning doesn't show any indication of what is causing the problem. But after having this issue, your method solved the problem. I am still curious to know your method of figuring this out. – Jesus Rodriguez Jan 20 '16 at 14:08
-
I think that simple's answer better explains the reason of the problem – allemattio Nov 28 '16 at 16:35
-
1
-
-
2
-
-
I'm building my UI programmatically and set the content mode to center. Removing that fixes the issue. What a frustrating error message. – DavidVII Apr 12 '20 at 22:24
Any layer change on a UIStackView
will result in this warning. As the warning points out UIStackView
is a transform-only layer and it differs quite slightly from a UIView
. As per documentation:
The UIStackView is a nonrendering subclass of UIView; that is, it does not provide any user interface of its own. Instead, it just manages the position and size of its arranged views. As a result, some properties (like backgroundColor) have no effect on the stack view. Similarly, you cannot override layerClass, drawRect:, or drawLayer:inContext:.
It may not point to the exact source of the OP's issue but hopefully, it will shed some light on why UIStackView
behaviour is not the same and should not be confused with UIView
.

- 1,491
- 12
- 14
-
2
-
-
1Thanks so much. I've been pulling my hair out trying to figure out why a UIView SUBCLASS doesn't react properly to drawRect override and layer manipulations... I think Apple should emphasize this about stack views way more in the docs. – jaga Feb 22 '17 at 15:46
-
Glad that I could help @jaga, agree with you on the emphasizing, there is no way to understand that when working with `UIStackView`s. – victor.vasilica Feb 24 '17 at 10:16
-
@victor.vasilica Let's say I'm creating a theme class to change colors globally within an app and I want all my `UIView`s to have a specified background color, should I do that work on the individual VC in `viewDidAppear` instead of trying to use UIAppearance? – Adrian Jan 24 '18 at 17:59
-
@Adrian your new question doesn't relate to the topic of this thread. It depends, my opinion is that UIAppearance should be avoided. I recommend using protocols, subclasses or composition to achieve it. Using `viewDidAppear` is also an option but it defeats the purpose of a global theme class. – victor.vasilica Jan 24 '18 at 18:13
-
@victor.vasilica Thank you. I'm getting the exact same error the OP encountered. I commented out the code I was using for `UIView` and it went away...and my `UIViews` that were generating the error were inside `UIStackViews`, though they render the color as desired. Concur re: `viewDidAppear`. I'm trying to do something that's "one stop shopping" without a bunch of book keeping on the individual VCs. I'll try your suggestion. Thanks again! – Adrian Jan 24 '18 at 18:22
It looks like what you did is perfectly correct.
However, I'm wondering why you chose to put your imageview into a stackview when you could have just as easily pinned the sides without the stackview. I am a big fan of stackviews but they don't make sense everywhere. Unless you're planning on adding new views, and resizing your ticktactoe board, I might not use it.

- 6,401
- 2
- 34
- 38
-
Well I can see that sometimes it would be nice to have stuff in stack views so you could change the orientation as needed without worrying about constraints and/or having two different classes to handle just two different orientations – Massimo May 24 '17 at 02:37
-
1I sometimes question myself for the use of StackView over pinning the views. I found that StackView is better choice for several reasons: #1 adding or removing elements will not break anything, #2 client (or designer) keep changing things, colleagues (or future me) won't have to worry about #1 when #2 happens – John Pang Nov 07 '17 at 02:21