Thank you for the opportunity to help you with your question!
As you stated earlier, a covalent bond is formed when atoms share a pair of electrons. Take note that this is an attraction force that exists between these atoms due to the sharing of the pair of electrons. For instance, methane has 4 hydrogen atoms surrounding a carbon atom. Each hydrogen donates an electron which forms a pair with the carbon electron resulting into a covalent bond.
On the other hand, an ionic bond is formed when two oppositely charged ions chemically bond. Atoms can either gain or lose electrons to form ions. Atoms lose electrons to form positively charged ion (cations) or gain electrons to form negaitvely charged ions (anions). when these opposite ions meet, they bond forming an ionic bond. For instance, sodium losses an electron to form Na(+) and chlorine gains an electron to form Cl(-). When the two ions bond, they form NaCl, an ionic bond.
Please let me know if you need any clarification. I'm always happy to answer your questions.