Obeying Islamic rules including Hijab or Islamic dress-code is necessary in Iran. However these rules are not observed very strictly, especially for tourists and foreigners.
1) Shorts are not acceptable in public places, especially in busy areas.
2) Jeans and T-shirts are acceptable.
3) Wearing ties or bows is not a problem.
You must not worry about maintaining your hijab, since in times you have forgotten about it, the maximum penalty will be a simple request to fix it correct (usually in a kind way). There are some minimum requirements for foreign women dress-code in public places :
1. Head : Hair should be covered. A loose scarf around your head is fine. Don’t worry, it is very usual that some parts remain out of the cover (bangs or polytail). Appropriate hats & caps can do this function as well as scarves. Scarf is the most common covering for head and is called “Roosari” in Farsi (on top of head).
3. Torso & Arms : Should be covered with loose clothes like a coat, manteau, or man shirt (not tight metro shirts). Arms should not be bare.
4. Legs & feet : Legs should be covered down to ankles. Feet can be bare and you can wear sandals. Tight jeans are not a problem, provided your torso is covered to upper thigh level.
Tip 1 : In winter, apart from covering your head, the fashion will be similar to your home country.
Tip 2 : In summer, you can remove the layers under your coat/manteau. Nobody would know.
Tip 3 : Try browsing on the internet for images of Iranian fashion in the streets.
Tip 4 : Whenever a chador (loose sheet) is needed, like in holy places, it will be given to you at the entrance.
Tip 5 : On flights, following the dress-code is necessary until your flight departs the Iranian airport. On Iranian flights, hijab is usually requested when the plane enters the Iranian boundaries at the airport. You'll know when to cover up by watching the Iranians on board prepare themselves.
Here's a more detailed guide for Girls Tips to Iran Hijab.