Solid-state single-crystal-to-single-crystal transformation from a 2D layer to a 3D framework mediated by lattice iodine release.