The Spanish actor explained that the shock experience in 2017 had helped to give him a better perspective on his life.
Banderas raised the subject while discussing his new film, Puss In Boots: The Last Wish where he plays the cat we first meet in Shrek 2 in 2004.
The new film sees the cat coming to terms with his own mortality as he reaches the last of his “nine lives”.
When asked if he could relate to the film in an interview with Radio Times, Banderas said: “I had a heart attack six years ago.
“It probably was one of the best things that happened in my life. It was like putting glasses on and seeing what was important,” the 62-year-old actor said.
“I came back to Spain and started looking at my professional life from a different point of view.
“So I do connect to it in a personal way. I think it’s a beautiful message, and I think it was done properly,” he added.
In an interview with The Independent in 2019, the actor echoed this sentiment in relation to his heart attack.
“I thought I was going to die, and it made me understand life in a deeper, more complex way,” he said at the time .
“I detached from things that are not important any more – the car, and this and that – and then I just put my attention in family, friends and in recovering... well, the essence of why I became an actor, and choosing to do more movies like this.”
While speaking to the Radio Times about his new film, the actor also explained that he was still attached to the character of the cat in his new film, even 19 years after first playing him.
“It has been a surprising, beautiful thing that happened to me with this character,” he said.
“I never thought that I was going to be called to perform...the voice of a cat in a language that I learnt when I was 32 years old. It’s a surprise.
“Life is like that sometimes. It just comes around the corner in a way that you don’t expect.”
The actor also explained that the film was “probably” based on his own experiences.
The full interview with Bandares will be available in this week’s Radio Times.
Additional reporting from PA News