Answer
If your artwork is made with only strokes or only fills (you could just outline all your strokes if you have fills too), then you can either create a compound path (select all and cmd+8 or Object → Compound Path → Make) and apply a gradient as either stroke or fill:
Or you can group your artwork and add the gradient to the entire group, or simply select an entire layer and add the gradient to an entire layer using the Appearance panel:
If your artwork is made up of both strokes and paths then it may be hard to get the continuous gradient to match over both…
Another option is to use your artwork as an opacity mask on a solid gradient.
- Group your artwork and make it all white.
- Place it on top of a solid gradient.
- With your gradient and artwork selected hit “Make Mask” in the Transparency panel.
Attribution
Source : Link , Question Author : Dabo Chen , Answer Author : Cai