How to avoid placement of objects with touch on top of UI (button)?

I am using Image as background which is a UI element.When I select/click a button and again touch on the screen containing the background image another sprite gets instantiated on the screen.After that when I go to click another button again the sprite gets instantiated on top of the button.How to avoid this.

I want the button to be clicked without instantiating already selected sprite on top of it.

 if (Input.touchCount > 0 && !EventSystem.current.IsPointerOverGameObject(Input.GetTouch(0).fingerId))
{
//As it disable the  instantiation of sprites that comes on the top of the background image.
}

If I use the above code I cannot instantiate by touching on background image which is a UI.I cannot remove the background image as it is important.This is a 2d project.

Use the IPointerClickHandler pattern for handling touch events. Unity has a built-in system for “consuming” events. In this case, you will “.use” on your pointer event.