Ios 如何将一个UIView设置为另一个UIView的掩码
我有Ios 如何将一个UIView设置为另一个UIView的掩码,ios,swift,uiview,swift4,cagradientlayer,Ios,Swift,Uiview,Swift4,Cagradientlayer,我有 gradientView这只是一个渐变视图 带有anImageView和aUILabel的视图容器视图 现在当我试着 gradientView.mask = containerView 它不显示任何内容UIImageView和UILabel都有固有的内容大小,但没有UIView。视图的遮罩必须正确设置边框。确保设置了containerView.frame: containerView.frame = gradientView.bounds 另外,请确保将containerView.ba
gradientView.mask = containerView
它不显示任何内容
UIImageView
和UILabel
都有固有的内容大小,但没有UIView
。视图的遮罩必须正确设置边框。确保设置了containerView.frame
:
containerView.frame = gradientView.bounds
另外,请确保将
containerView.backgroundColor
设置为UIColor.clear
我只想添加视图背景颜色应为的其他内容clearColor@AsadullahAli那么它不起作用了?或者,视图的背景色应该是clearColor是什么意思?这是正确的一半。我必须添加containerView.backgroundColor=UIColor。clear@AsadullahAli哦,好的,我会更新答案。。我希望containerView
的背景色是clearColor,因为这是UIView
的默认背景色,当我们从故事板添加它时,默认颜色是白色,这会浪费我数小时的时间,所以最好让其他人知道。