Reset or clear the UIView from UILabels

Posted by Nicsoft on Stack Overflow See other posts from Stack Overflow or by Nicsoft
Published on 2010-06-06T10:45:46Z Indexed on 2010/06/06 10:52 UTC
Read the original article Hit count: 659

Filed under:
|
|
|
|

Hello,

I have created an UIView on which I have a number of labels and I'm also drawing some lines in the same UIView. Sometimes I update the lines that I'm drawing.

Now, the problem I am having is that when I update the lines, they get drawn according to my wish. But the labels are overwriting themselves. This shouldn't have been a problem if it wasn't for that the position is changed about 1 pixel and that makes the text go blurry.

I don't know how to remove the labels before they are redrawn. I do remove the labels from the superview and add them back when drawRect is called, but the SetNeedDisplay doesn't clear the screen before the graphic is updated, I guess (I think I read that SetNeedsDisplay/drawRect doesn't clear the screen, just updating the content. Couldn't find the text now while searching)? What is the pattern to use here, should I create a retangle with the size of the screen (or the area where the labels are) and fill it with the background colour, or is there any other way to clear or reset the UIView (I don't want to release and create the UIView again).

The view is created in IB and associated with a custom UIView. In IB I add some buttons and other static labels. The above labels and graphics is created programatically.

Any comments would be helpful! Thanks in advance!

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c