A big part of it is having a good grasp of you and your opponent's range(s). This is crucial because you're going to want to move only as far into their range as you have to in order to be able to land your own strikes. Another big part is timing; you're going to want to move in when your opponent's not expecting it (feints can help with this) or when he's in a position that won't allow him to defend effectively (Ex: after he throws a kick or misses a hook). You're going to want to move away just before he starts throwing his strikes. I've found that one good way of telling when someone that's moving is about to throw a punch is by watching for when they plant their feet. Also, don't get greedy - most of the time when you're doing this it'll be 15-20 seconds or more between exchanges and even when you do exchange you'll probably only land 2 or 3 punches, but if you're doing it right he should be landing even fewer.
So in general you're going to want to stay outside of his range until you see an opening. Then you stick, and you move. Away. Quickly, and at an angle.
"I don't want them to like me, because when I'm in the ring, punches fly to the face. It is not a tenderness time. I am not falling in love. And he knows that when the fight starts I am kicking faces."
- Wanderlei Silva