Your iPhone is not hacked. It is nearly impossible to hack your iPhone unless it is jailbroken. What you saw is a fake notification while browsing a website. These fake websites/notifications get you to click on a link and probably lead you to a fake login page and capture your credentials. You did not click on anything and you did not download anything. You are fine.
Below is some more reading on all about scams and phishing:
All about scams and phishing -
Beware of ➔ Phishing & Other Suspicious Emails
Know how to Identify legitimate emails from the App Store or iTunes Store
Avoid phishing emails, fake 'virus' alerts, phony support calls, and other scams ➔ Use these tips to avoid scams and learn what to do if you think your Apple ID has been compromised.
Axel F.