How to remove text after drawInRect?

I have a UIView subclass called BackgroundText to draw some text.

-(void) drawRect:(CGRect)rect
{
    [@"synchronized." drawInRect:CGRectMake(0, 29, 320, 60) withFont:bigFont lineBreakMode:UILineBreakModeTailTruncation alignment:UITextAlignmentRight];
}

--

backgroundText = [[MMRoomBackgroundText alloc] initWithFrame:CGRectMake (0, 142 + 44, 320, 80)];
[self.view addSubview:backgroundText];

I expect [backgroundText removeFromSuperview]; can remove these text from screen,but it doesn't work.

Thanks.

Answers


You need to call setNeedsDisplay on the view and check.


I hope this will help you.

Here LoadingBG is My View And LoadingText is My Label And I am Putting Text in Label and Add Label into View and After that I remove View From SuperView When I dont Need Text.

For Adding Text:

UIView * LoadingBG = [UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460);
UILabel *LoadingText = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 50)] autorelease];
LoadingText.text = @"Loading...";
LoadingText.backgroundColor = [UIColor clearColor];
[LoadingBG addSubview:LoadingText];

For Remove Text:

[LoadingBG removeFromSuperview];

And Here I had Use Fixed Size For View And Label. You can Use What You want as a frame.


Need Your Help

How can I convert those two loops using map and filter?

python

I try to write this code using the map and filter built-in functions. How can I do it?

What would be an example of a call back handler of type 'GMSReverseGeocodeCallback!' for the reverseGeocodeCoordinate() function?

ios swift google-maps sdk

What would be an example of a call back handler of type GMSReverseGeocodeCallback! for the reverseGeocodeCoordinate() function?