The gunman was later taken into custody without incident, and no injuries were reported.
Officers responded to reports of shots fired in the area of W. 42nd Street and Walton Avenue about 3 a.m., according to the Los Angeles Police Department.
It was unclear if the suspect was a resident of the apartment. A family that was inside was able to escape safely.
The scene was near Manual Arts High School, but no cancellation of classes was immediately announced.