This paper presents a two-step optimization-based design method for iterative learning control and applies it onto the quad-rotor unmanned aerial vehicle's (UAV's) trajectory tracking problem. Iterative learning control aims to improve the tracking performance through learning from errors over iterations in repetitively operated systems. The tracking errors from previous iterations are injected into a learning filter and a robust filter to generate the learning signal. The design of the two filters usually involves non-trivial tuning work. This paper presents a new two-optimization design method for the iterative learning control, which is easy to obtain and implement. In particular, the learning filter design problem is transferred into a feedback controller design problem for a purposely constructed system, which is solved based on H-infinity optimal control theory thereafter. The robust filter is then obtained by solving an additional optimization to guarantee the learning convergence. Through the proposed design method, the learning performance is optimized and the system's stability is guaranteed. The proposed two-step optimization-based design method and the regarding iterative learning control algorithm are validated by both numerical and experimental studies.