首页 > 解决方案 > 如果我们在 Parchment 的 HeaderExample 中替换 UIView 而不是 UIImageView,则渐变背景不起作用

问题描述

我在我的应用程序中使用羊皮纸库进行分页。当我在 Parchment 的标题示例中将 UIImageView 替换为 UIView 时,渐变背景不起作用。我只看到白屏。

如果我在视图中单独添加渐变效果,使用羊皮纸,我相信它被某些层重叠。我也试过这个链接但没有用。 https://github.com/rechsteiner/Parchment/issues/181

实际结果是标题视图中的白屏,预期是渐变填充。

标签: swiftuiviewuiimagegradientparchment

解决方案


The UIImageView.... if the gradient is being displayed as a bitmap in the .image of the UIImageView, that would explain the gradient disappearing.

UIView’s do not have a .image - That is why UIImageViews are needed to display bitmaps.


推荐阅读