如何更改UIStackView的背景颜色? [英] how to change the background color of UIStackView?
问题描述
我试图在Storyboard检查器中将 UIStackView
背景从clear更改为white,但在模拟时,堆栈视图的背景颜色仍然具有清晰的颜色。 >
如何更改 UIStackView
的背景颜色?
I tried to change the UIStackView
background from clear to white in Storyboard inspector, but when simulating, the background color of the stack view still has a clear color.
How can I change the background color of a UIStackView
?
推荐答案
你不能这样做 -
UIStackView
是一个非绘图视图,意味着
从不调用drawRect()
并忽略其背景颜色。如果
迫切需要背景颜色,可以考虑将堆栈视图
放在另一个UIView
中,并为该视图提供背景颜色。
You can't do this –
UIStackView
is a non-drawing view, meaning thatdrawRect()
is never called and its background color is ignored. If you desperately want a background color, consider placing the stack view inside anotherUIView
and giving that view a background color.
来自 HERE 。
这篇关于如何更改UIStackView的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!