A lightweight, UIKit+AppKit-friendly way to either mask content, or show a loading state. Think: SwiftUI's 'redacted' modifier, for non-SwiftUI applications on iOS + macOS.
You can look through the code, but tl;dr, the effect is recursively applied as a CALayer
per subview* (with optional
use of CAGradientLayer
and CAAnimation
depending on your settings). These layers should be removed
automatically for you when the effect is shut down.
(* Note: 'per subview' here refers to the absolute bottoms of the view hierarchy. I.e., thinking of it as a tree data structure, the effect will only be applied to leaves.)
I don't have much in the way of AppKit experience, so it may not function as smoothly with NSView
s as it does for UIView
s.
Let me know if anything pops up there.
-
Install the package, which can be done via Swift Package Manager.
-
Decide where you want to invoke the scintillating effect. To start it, you just need to provide the root view within which you want to apply the effect (remember it's recursive!), and any custom settings you wish.
For instance:
Scintillate.kickStart(in: stackView)
would start the scintillating effect with default settings (no animation, and a default color).
To turn the effect off, simply call shutDown
on the same view:
Scintillate.shutDown(in: stackView)
This can be done via a ScintillateSettings
that you may construct and pass into the kickStart
method.
It allows you to enable animation (default is off), render the mask as a gradient, and customize a color (if you
choose to animate and/or make the mask a gradient without specifying a secondary color, one will be interpreted
based on the primary color).
- Check tablet appearance + fix rotation behaviour
- Make color customizable
- Actually make them shiny (read: animate the layers)
- Add more options for customization (maybe)
- Refine animation speed (and maybe make customizable ^)
- All the bugfixes