This paper investigates a novel unmanned aerial vehicle (UAV) secure communication system with integrated sensing and communications. We consider wireless security enhancement for a multiple-antenna UAV transmitting ISAC waveforms to communicate with multiple ground Internet-of-Thing devices and detect the surrounding environment. Specifically, we aim to maximize the average communication secrecy rate by optimizing the UAV trajectory and beamforming vectors. Given that the UAV trajectory optimization problem is non-convex due to multi-variable coupling develop an efficient algorithm based on the successive convex approximation (SCA) algorithm. Numerical results show that our proposed algorithm can ensure the accuracy of sensing targets and improve the communication secrecy rate.