Yes, but only if you purchase an unlocked iPhone from Apple (ie. without a contract).
If you buy a subsidised iPhone it will be locked to the network you bought it with. You will need to get in touch with them for information on how to unlock it. Note that once your contract is over they are obligated by UK law to assist you in unlocking the device.