【发布时间】:2018-05-06 13:54:04
【问题描述】:
我想创建一个渐变层并将其插入到视图中,但视图没有完全填充...
我的实际代码是:
gradientLayer.frame = topView.bounds
gradientLayer.colors = [UIColor.white.cgColor, UIColor.black.cgColor]
topView.layer.insertSublayer(gradientLayer, at: 0)
This is my code and storyboard (In red is the part I want to fill)
我对此一无所知..它适用于全屏视图,但不适用于更多小视图..
顶视图当然是从情节提要中导入的。也许我在 view.bound 上犯了一个错误,我不知道。我是 swift 和 iOS 的初学者,所以一切皆有可能!
编辑: 问题不在于视图的大小,而是图层的大小太小,因为视图的背景颜色填充了所有空间而不是图层
【问题讨论】:
-
如果将 topView.bounds 更改为 topView.frame 会发生什么?
-
还是一样的结果
标签: ios iphone swift uiview cagradientlayer