Cu(OH)$_2$ dissolves in aqueous ammonia due to complex formation.
In excess NH$_3$, Cu$^{2+}$ forms the deep-blue ammine complex:
\[
\mathrm{Cu(OH)_2\;+\;4\,NH_3\;+\;2\,H_2O\;\longrightarrow\;[Cu(NH_3)_4(H_2O)_2]^{2+}\;+\;2\,OH^-}
\]
This complex is soluble, so the precipitate dissolves.
In NaOH, no such soluble cuprate complex is formed (Cu(OH)$_2$ is not appreciably amphoteric),
hence Cu(OH)$_2$ remains as an insoluble blue precipitate.