Effects of magnetic fields on anisotropies in the arrival direction of ultra-high-energy cosmic rays