Are they old enough to try having a serious talk with them about what is ok and what isn't, and to let them tell you which things they feel "got at" over? You can end up in a situation where neither side is happy, but don't see how to change.
DS1 was in tears because I made him wear his sun hat this morning. He is 8.
He shrugged me off when I put my arm around him so I left him alone. Once I had dropped off DD I asked him if he was talking to me yet and he said he always had been and could he have £24 for a light saber.
I think the problem with either getting angry at them, or telling them to do as they like is that they don't know where they stand, and the only way they can work out what is allowed and what isn't is by pushing the boundaries until you snap. And you'll nearly always snap before they give up, because children seem to have a huge amount of stamina!
What was the issue with the sunhat? Does he think he's too old to need one? Could you negotiate with him - find out what sort of hat would be ok? If you can make him understand that a hat of some kind is not optional, but he can pick out something suitable (within limits) then it might not need to become a problem.
Same with other things - he may want more freedom, but you still need to know he's safe. But if you can start up a discussion of what your requirements are, and where you're prepared to be flexible, then you can hopefully get back into a position where you both understand the other's point of view.