Heavy ion beam drivers, due to their high kinetic energy, offer the potential for transferring a large amount of energy to the witness beam. Limited by the relatively low velocity of heavy ion, the dephasing length is short leading to a low energy gain of the witness beam. The conventional method that linearly increasing the plasma density is ineffective because the mismatch between the RMS beam radius and plasma skin depth will make the wakefield degrade or even disappear. In this paper, we propose a method that periodically increases and decreases the plasma density to switch the witness beam between different accelerating phases, allowing it to shift between adjacent accelerating cavities. Using this method, electrons can be accelerated up to 1.34 GeV in a distance of 1.17 m, with an energy spread of 1.1%. This method helps maintain the structure of wakefield and increase the energy transfer efficiency. It provides a potential route for generating high energy, high intensity electron beams and offers a feasible path for future heavy ion driven plasma wakefield acceleration experiments.