UAV swarm has emerged as a crucial new combat force in information warfare. To tackle the challenges of collective shape control in UAV swarms driven by multiple tasks, a phase transition control method for UAV swarms inspired by birds’ behavior is proposed. Firstly, the behavioral patterns of bird flocks are analyzed, and the characteristics of collective defense behavior in bird flocks exemplified by sparrows are summarized. Then, a phase transition control model for UAV swarms based on four rules (four-rules phase transition model, FRPT) is built by introducing centripetal/centrifugal dual force and establishing “mutation” interaction rules. Next, with control parameters and order parameters defined and key control parameters regulated, the phase transition control of UAV swarm is achieved and the effectiveness of the proposed method is experimentally proved. Finally, through the optimal parameter solving of swarm intelligence optimization algorithms, the formation period of ordered phases is shortened by nearly 70%, which validates the optimization feasibility of the proposed method.The method is anticipated to be extensively applied in tasks such as reconnaissance and emergency rescue missions for UAV swarm perception.