0

Lots of examples on how to do create a glow effect on iOS UIView, but how do you do it on macOS? Preferably in Swift.

Thanks.

Aaron Bratcher
  • 6,051
  • 2
  • 39
  • 70

1 Answers1

3

Your question is a little vague (in particular, what is a "glow effect"?), but what I think you mean is a shadow effect with a light colour instead of a dark colour.

For this, you merely have to configure the NSView layer's shadow property, as per the documentation at:

https://developer.apple.com/reference/appkit/nsview/1483263-shadow

Give the shadow a (0,0) offset to centre it behind the view, give it a decent radius around the edge of the view, and give it a light glowing colour, and appropriate opacity.

Complete code example is at: How to display shadow for NSView?

If shadow is not what you're after, you may need to edit your question and elaborate on what you mean.

Community
  • 1
  • 1
Son of a Beach
  • 1,733
  • 1
  • 11
  • 29
  • I second this, and further, any glow effect you find in iOS that uses Core Animation can fairly easily be adopted to OSX -- there are some extra steps you need to do, like set up the layer, and compensate for the flipped y-axis, but these should be fairly well documented. – joeybladb Feb 24 '17 at 02:54