One of the thirty-nine categories of forbidden activity on Shabbat is "Zoreh," winnowing. After threshing harvested grain, which has the effect of cracking open the shells surrounding the kernels, farmers would throw the grain into the air to allow the wind to carry away the chaff, with the kernels falling to the ground. According to the Talmud Bavli's understanding of this Halacha, the prohibition of "Zoreh" forbids separating desired elements from undesired elements in this fashion. The Talmud Yerushalmi, however, extends this prohibition to include any instance of having something scattered in the wind.
The Rama (Rabbi Moshe Isserles, Poland, 1525-1572), in his glosses to the Shulchan Aruch (end of Siman 319), rules that one who spits into the air, such that the wind scatters his spittle, is liable for "Zoreh." This ruling is based upon the Yerushalmi's understanding of this prohibition, whereby it applies to all instances of scattering a substance through the wind. According to the view of the Talmud Bavli, however, "Zoreh" is limited to cases where one separates desired substances from undesired substances via the wind. It therefore would not apply to the case of spitting, where the entire substance is undesired. (Menuhat Ahava, Helek 2, page 207.)
A common, modern-day application of this debate is the issue aerosol sprays. According to the Yerushalmi's definition of "Zoreh," spraying an aerosol would indeed violate this prohibition, as it involves emitting a substance into the air where it is then scattered by the wind. According to the Bavli, of course, the prohibition of "Zoreh" would not apply to aerosol sprays.
The Halachic authorities have generally rejected this position of the Rama. The Mishna Berura (commentary to the Shulchan Aruch by Rabbi Yisrael Meir Kagan, the "Chafetz Chayim," Lithuania, 1839-1933) observes that nobody makes a point of refraining from spitting into the wind on Shabbat. He writes that when one spits into the wind he has no intention for the spittle to be scattered by the wind, and also this quite obviously differs fundamentally from the process of winnowing. Chacham Ovadia Yosef, in his work Yechaveh Da'at (Helek 6, siman 25), likewise dismisses this view and permits the use of aerosol sprays on Shabbat, and this is the position as well of Rabbi Moshe Halevi, in his work Menuchat Ahava (Menuhat Ahava, Helek 2, page 207.)
Summary: It is permissible to spray aerosols on Shabbat.