The classical Ant Colony Optimization (ACO) has some problems such as slow convergence speed and easy to fall into local optimum, a control method for dense formation of UAVs is proposed in this thesis. Firstly, cubic mapping is used to initialize the ACO distribution for making full use of map information and avoiding falling into local optimum; Secondly, the pheromone concentration updated by reward and punishment mechanism. Adaptive pheromone volatility factor is used to balance the global search and local search, as well as accelerate the convergence of the algorithm; Then, the artificial potential field is combined with the ACO to optimize the obstacle avoidance path. Finally, the state information from the dense formation of UAVs is corrected according to the consistency control theory, and the formation consistency control model is designed to realize the dense formation control. The experimental results shows that the proposed algorithm can achieve obstacle avoidance while maintaining tight formation, the formation can converge to the desired formation quickly after the obstacle avoidance is completed.