Active shielding technology has been widely applied to the superconducting magnetic resonance imaging (MRI) and nuclear magnetic resonance (NMR) magnets design, revealing excellent performance on the stray field control. For such a highly homogeneous field superconducting magnet design, an appropriate optimization strategy is essential to guarantee the magnetic field homogeneity in the central region and the expected 5 Gauss line range, especially for the ultrahigh field superconducting magnet. Based on the compensating field optimization method, an actively-shielded whole-body 14T MRI magnet and an actively-shielded 1.3GHz NMR magnet were presented, and detailed analyses were conducted to evaluate the feasibility of the designs. The developed magnet design method, coil pattern, wire arrangement, and stress/strain adjustment will be used to guide the corresponding project implementation.