Yes, the sun has to shine to make rainbow. The basic conditions that must be available to form a rainbow are: Suspended water droplets, which may be in the form of fog, water mist, or rain, in addition to bright sunlight, and a right angle to the sun, where the sun must be behind the viewer or observer