We study the time evolution of entanglement entropy and entanglement spectrum in a finite-size system which crosses a quantum phase transition at different speeds. We focus on the Ising model with a time-dependent magnetic field, which is linearly tuned on a time scale $\tau$ . The time evolution of the entanglement entropy displays different regimes depending on the value of $\tau$, showing also oscillations which depend on the instantaneous energy spectrum. The entanglement spectrum is characterized by a rich dynamics where multiple crossings take place with a gap-dependent frequency. Moreover, we investigate the Kibble-Zurek scaling of entanglement entropy and Schmidt gap.