As flying relays, UAVs can quickly set up relay communication links for different missions, to enhance the receiving signal power, increase the system capacity, and expand the communication coverage. In this paper, we investigate a non-orthogonal multiple access (NOMA) based UAV relaying network that helps data transmission from a base station (BS) to remote multiple users. To improve spectral efficiency of the investigated UAV relaying network, we provide a generalized user grouping protocol that partitions users into multiple groups and transmit data via NOMA within the same group. Then, we further formulate a joint optimization problem of the NOMA user grouping, the UAV position, and the UAV transmit power to maximize the system throughput. The formulated problem is non-convex which makes it difficult to solve directly, hence, we propose an iterative algorithm to obtain an approximate optimal solution. Simulation results demonstrate that our proposed NOMA-based UAV relaying scheme achieves significant throughput gains compared with other benchmark schemes.