If the shirt truly did violate the dress code then I think the teacher had every right to tell the kid to reverse it - but I wonder about eh fact that he was already in 5th period lunch , so I assume he had already been in homeroom and 4 classes with at least 4 teachers and no one else was bothered enough to make an issue about this
While I strongly believe that rules are there to be obeyed I also have seen some teachers who are confrontational and over impressed with their own importance and authority. There was the idiot teacher in my high school who tried to make an boy from an orthodox Jewish family remove his yamulke because hats were not allowed in school - the boy refused, was sent to the principal and returned 15 minutes later with a note for the teacher and his yamulke in place
I was a member of the site committee for the Vixters primary school and I campaigned long and hard for a uniform - but I could not get the support-