A contact lens includes a hydrogel that includes a three-dimensional network of cross-linked polymer chains; and at least one ophthalmic drug embedded in the three-dimensional network of cross-linked polymer chains. In the contact lens, the hydrogel includes a first repeating unit derived from hydroxyethyl methacrylate and a second repeating unit derived from N-isopropylacrylamide. The hydrogel including the first and second repeating units is configured to swells when absorbing water such that, when the contact lens is placed in or contacts an aqueous solution having pH in a range between 5.80 and 8.03, the lower the pH of the aqueous solution within the range, the more the hydrogel absorbs water and swell and the more the contact lens releases the at least one ophthalmic drug into the aqueous solution.