I have to say, I would be royally pissed if an employer had a problem with my attitude, as well as being aware of other coworkers having problems with my attitude, but didn't notify me of it until it was time for me to leave. To me, there is just something so wrong about that. I'm very much an advocate of self-critique and self-improvement, but sometimes that can't happen without the input of other people.
The fact that he waited so long to tell you all of this makes me think he wasn't doing his job properly as a supervisor. Evidently, he received these complaints, and did virtually nothing about them until you were leaving. That sort of inaction brings his competence as a supervisor into question.
Nevertheless, don't let these words of mine go to your head. What he did finally tell you is a very important lesson, perhaps in humility, among other things. Teamwork is a skill you have to learn, and I do believe it is learnable, depending on the person. Just don't give into despair or self pity. We all have our demons that we must do battle with, and we've only lost when we surrender. Of course, being aware and honest of their existence is half the battle, so perhaps now that you are aware of it, you can begin improving yourself in that respect.
But yeah, I like quadraphonics' suggestion to consult with your coworkers and get their direct input. I would also contact the supervisor for further answers, perhaps specifics, and ask why he waited so long to tell you all of this. Maybe he has a reason? I can't imagine one good enough, as doing so is utterly inconsiderate, disrespectful, and incompetent. Do these things politely, of course. Politely explain your situation and ask for honest answers. Be sincere in your desire for self-improvement. If you receive harsh criticism, don't get angry (but don't get sad either).