High-precision magnetic field measurement is an ubiquitous issue in physics and a critical task in metrology. Generally, magnetic field has DC and AC components and it is hard to extract both DC and AC components simultaneously. The conventional Ramsey interferometry can easily measure DC magnetic fields, while it becomes invalid for AC magnetic fields since the accumulated phases may average to zero. Here, we propose a scheme for simultaneous measurement of DC and AC magnetic fields by combining Ramsey interferometry and rapid periodic pulses. In our scheme, the interrogation stage is divided into two signal accumulation processes linked by a unitary operation. In the first process, only DC component contributes to the accumulated phase. In the second process, by applying multiple rapid periodic $pi$ pulses, only the AC component gives rise to the accumulated phase. By selecting suitable input state and the unitary operations in interrogation and readout stages, and the DC and AC components can be extracted by population measurements. In particular, if the input state is a GHZ state and two interaction-based operations are applied during the interferometry, the measurement precisions of DC and AC magnetic fields can approach the Heisenberg limit simultaneously. Our scheme provides a feasible way to achieve Heisenberg-limited simultaneous measurement of DC and AC fields.