Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
331 views
in Technique[技术] by (71.8m points)

ios - 免除阴影阴影(Exempt shadow from screen blending)

Trying to use a View.shadow(...) function in SwiftUI to create a glow effect around an object in concert with the View.blend(.screen).

(尝试在SwiftUI中使用View.shadow(...)函数与View.blend(.screen)配合在对象周围创建发光效果。)

When I layer the objects without the shadow, they are the proper colors and blend properly:

(当我对没有阴影的对象进行分层时,它们是正确的颜色并正确混合:)

所需颜色

When I add the shadow, each object's shadow seems to blend with the object itself, shifting the colors:

(当我添加阴影时,每个对象的阴影似乎都与对象本身融合在一起,从而改变了颜色:)

阴影混合色

Is there any way to have the shadow not blend with it's associated object?

(有什么办法可以使阴影不与其关联对象融合?)

Code snippit:

(代码段:)

Path(path1)
    .foregroundColor(Color(color2))
    .shadow(color: Color(color), radius: 5, x: 0, y: 0)
    .blendMode(.screen)
Path(path2)
    .foregroundColor(Color(color2))
    .shadow(color: Color(color), radius: 5, x: 0, y: 0)
    .blendMode(.screen)
  ask by Spencer Connaughton translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...