Highlights
•
A superhydrophobic surface with a flowerlike structure was prepared on magnesium alloy.
•
Contact angle is 167.3 ± 1.3° and sliding angle is about 1°.
•
The superhydrophobic surface possessed an excellent anticorrosion effect.
•
The corrosion rate of the resulting surface is 0.06% of that of bare magnesium alloy.