I wanted to place a UI progressbar over my players head therefore I created another layer called UI and placed the sprite on the desired location but when I press play the real position of the sprite is totally off.
Please help me solve this problem.
That is correct.
While all of the x/y positions of the objects will remain the same, each layer has a unique camera. By creating a UI layer, any events on the first layer that move the camera will not apply to the other layers.
If you want the UI bars to follow the player, and your player moves the camera of the base layer, you will also have to move the camera of the UI layer the same way.
Thanks for your reply Silver-Streak it solved my problem.