My almost-3-year-old goes through this every so often. Sometimes it's brought on by illness, poor sleep, or some change in routine that I can point to (new bed, potty training, travel or visitors). Other times it just seems to be a stage she's going through. Typically her more cheerful side comes out after a few days.
When she gets whiny we ask her to restate her request without whining before giving her what she wants, or we explain that she's not going to get what she wants, offer alternatives, and deal with the tantrum if necessary. Occasionally to give me (mom) a break we have someone else take her, despite her protests, for an hour or two, and we usually find that she's happy enough once she gets away from me. Other than that, I try to give her lots of reinforcement that I love her and give her some special time when we do those things she's been asking to do. Role modeling positive response to situations also seems to help in the longer term. (Naming the things you and she enjoyed doing that day, stating what you're thankful for, praising when she or others do something well.)