Can you have sex while treating a UTI?

I mean I already did it, but for future reference...can you?