Postoperative endophthalmitis (POE) has been the most threatening complication after cataract surgery, which perhaps can be solved by the antibiotic-loaded intraocular lens (IOL). However, most drug-loaded IOLs demonstrate insufficient drug quantity, short release time, increased implantation-related difficulties or other noticeable drawbacks. To prevent POE and to address these deficiencies, a drug-loaded copolymer IOL, prepared from poly (urethane acrylate) prepolymer, isobornyl methacrylate (IBOMA), N-vinyl-2-pyrrolidone (NVP), Irgacure 819, RUVA-93, and gatifloxacin (GAT), was rapidly fabricated via photocuring and by using a 3D-printed mold. This composite displayed an outstanding and controllable GAT release behavior in vitro, a high light transmittance, and a moderate refractive index. Also, it demonstrated improved strain stress and elongation compared with the reference commercial acrylic IOL material. In vivo tests demonstrated satisfying released drug concentration at the early treatment stage. In vitro and in vivo studies further confirmed the remarkable bacterial inhibition and prevention of POE by the proposed IOL, which also displayed good biocompatibility. These findings suggested that the GAT-loaded IOL could be a promising implant to prevent and cure POE, also the proposed methods could inspire more designs for various medical applications. © 2022 The Authors.