如何更改UIStackView的背景颜色? [英] how to change the background color of UIStackView?

查看:407
本文介绍了如何更改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 that drawRect() is never called and its background color is ignored. If you desperately want a background color, consider placing the stack view inside another UIView and giving that view a background color.

来自 HERE

这篇关于如何更改UIStackView的背景颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆