In recent years, unmanned aerial vehicle (UAV) has been widely adopted in military and civilian applications. For small UAVs, cooperation based on communication networks can effectively expand their working area. Although the UAV networks are quite similar to the traditional mobile ad hoc networks, the special characteristics of the UAV application scenario have not been considered in the literature. In this paper, we propose a distributed gateway selection algorithm with dynamic network partition by taking into account the application characteristics of UAV networks. In the proposed algorithm, the influence of the asymmetry information phenomenon on UAVs' topology control is weakened by dividing the network into several subareas. During the operation of the network, the partition of the network can be adaptively adjusted to keep the whole network topology stable even though UAVs are moving rapidly. Meanwhile, the number of gateways can be completely controlled according to the system requirements. In particular, we define the stability of UAV networks, build a network partition model, and design a distributed gateway selection algorithm. Simulation results show using our proposed scheme that the faster the nodes move in the network, the more stable topology can be found, which is quite suitable for UAV applications.