Reputation: 75
I am writing a simple game for the iPhone/iPad and am having trouble handling touches like I want to.
I have a main view of class Board
which contains several views of class Piece
. When a user touches a piece, I want to make it change colors. I have a property of type UIColor
in the Piece
class that holds the color of the object, and I can successfully change that upon touching.
My question is this: How do I change the fill color of my piece to reflect what the property says it is?
Upvotes: 0
Views: 218
Reputation: 7102
If you have implemented drawRect
on your Piece class then you'll need to do the appropriate core graphics calls to set the fill color or stroke color to match your color property. If you've already done that then maybe you need to call [thePiece setNeedsDisplay]
after changing the color property.
If you haven't and don't plan on implementing drawRect for your Piece class then you might be better off using the existing UIView property backgroundColor
instead of your own color property.
If you post some of your code I can probably give you more specific advice.
Upvotes: 2