iOS White to Transparent Gradient Layer is Gray

前端 未结 7 1212
清歌不尽
清歌不尽 2021-02-01 11:53

I have a CAGradientLayer inserted to the bottom of this small detail view that pops up at the bottom of the app. As you can see, I\'ve set the colors from white to clear, but th

7条回答
  •  孤城傲影
    2021-02-01 12:07

    It's worth noting that to handle white/black (or really any color with light/dark appearances) gradients based on light/dark mode in iOS 13 that this approach also works with the new system colors:

    gradientLayer.colors = [
        UIColor.systemBackground.cgColor,
        UIColor.systemBackground.withAlphaComponent(0).cgColor] 
    

提交回复
热议问题