Calvin Harris has hit out at his ex-girlfriend Taylor Swift after it was confirmed that she did write his latest hit.

The Scottish DJ posted a string of messages on Twitter, saying Swift's behaviour was "hurtful" and alluding to her new romance with Tom Hiddleston after Swift's camp said she penned Harris and Rihanna's track This Is What You Came For.

Her spokesperson said: "Taylor Swift wrote This Is What You Came For under the pseudonym Nils Sjoberg."

Harris - who split from Swift in May - shared a link to a US article about Swift writing the song and tweeted: "And she sings on a little bit of it too. Amazing lyric writer and she smashed it as usual."

He went on to say Swift wanted the arrangement a secret but that he would it "hurtful" how her team was going out of their way to make him look bad.

The star then referenced Swift's new relationship with actor Hiddleston and also referred to Swift's rumoured feud with pop star Katy Perry, tweeting: "I know you're off tour and you need someone new to try and bury like Katy ETC but I'm not that guy, sorry. I won't allow it.

"Please focus on the positive aspects of YOUR life because you've earned a great one."

Harris concluded his rant by tweeting: "God bless everyone have a beautiful day."

Swift, 26, and Harris dated for 15 months before parting company in late May.

The Shake It Off singer started dating Hiddleston weeks after the break up.