One route is to use the Poisson kernel representation of $f$. This can be derived in may ways, eg, Derivation of the Poisson Kernel from the Cauchy Formula. (This formulation works for functions analytic on $B(0,R)$, but can be easily extended to deal with functions analytic on $B(0,R)$ and continuous on $\overline{B}(0,R)$.)
Let $B$ be the open unit ball. For $0\leq r < 1$, the Poisson kernel representation gives $f(r e^{i\theta}) = \frac{1}{2 \pi} \int_{-\pi}^\pi P_r(\theta -t) f(e^{it}) dt$, where $P_r(\theta) = \text{Re} \frac{1+re^{i \theta}}{1-re^{i \theta}}$. It follows from this that if $f(e^{i t})$ is real for all $t$, then $f(r e^{i\theta})$ is real for all $0\leq r < 1$. Hence $f(z)$ is real for all $z \in B$.
If $f(z)$ is real for all $z \in B$, it follows that $f'(z) = 0$ for $z \in B$ (if $f'(z_0) \neq 0$, then by looking at $\phi(t) = f(z_0+i t \overline{f'(z_0)})-f(z_0)$, it is straightforward to contradict $f(z)$ being real). Since $B$ is connected, it follows that $f$ is constant on $B$.