This follows from the Maximum Modulus Theorem. However, the proof that comes to mind of the Maximum Modulus Theorem using the Cauchy Integral Formula actually uses this fact, so that might be circular.
To prove this special case of the Maximum Modulus Theorem, Pete L. Clark has already mentioned that the Open Mapping Theorem applies.
An alternative is to use the Cauchy-Riemann equations. If $f(z)=f(x+iy)=u(x,y)+iv(x,y)$, by hypothesis there exists a constant $r\geq 0$ such that $u^2+v^2 = r^2$. It follows that $uu_x+vv_x=0$ and $uu_y+vv_y=0$. You also have $u_x=v_y$ and $u_y=-v_x$. A little algebraic manipulation yields $u(u_x^2+v_x^2)=v(u_x^2+v_x^2)=0$. Assuming $r\neq 0$, $u$ and $v$ are never simultaneously $0$, so it follows that $u_x^2+v_x^2\equiv 0$, which implies that $u_x=v_y=0$ and $v_x=-u_y=0$. Therefore $f$ is constant.
Another way to use the Cauchy-Riemann equations is to first map the circle $|z|=r$ into the real axis, either using a Möbius tranformation, or using logarithms. E.g., consider $g\circ f$, where $g(z)=i\dfrac{1+\frac{z}{r}}{1-\frac{z}{r}}$. (Such maps won't be defined on the entire circle, but it is enough to show that $f$ is locally constant.)