KPZZSS
KPZZSS

Reputation: 31

Calling Drawrect manually

I am creating a custom view with UIBezierPath drawing. I want to update the custom view fill color whenever state changes based on response from server. I am using fillColor property as a param to update view's color. How can i change the fillcolor programmatically?

Upvotes: 1

Views: 586

Answers (1)

matt
matt

Reputation: 535999

You must never call drawRect. Instead, call setNeedsDisplay, and drawRect will be called for you. As for changing the color, it's just a matter of planning ahead — put the color where your drawRect routine can find it. Thus, for example, if you have a property holding the fill color, you can change that and call setNeedsDisplay, and the view can thus be redrawn using the new fill color property value.

Upvotes: 5

Related Questions