简体   繁体   中英

how can I draw /redraw a line from main view into subview in iphone?

I want to draw as well as redraw some lines from view into my sub-view say I have big view and I want to draw a line inside my mySubView. I know by the help of drawrect event I can draw some line but this event calls only once at the starting of the program actually I want to put some button and then draw my lines and stuffs like that whenever I want.

In your buttonPush action handler, call the setNeedsDisplay , it will mark the view's entire bounds rectangle as needing to be redrawn ( thus , your drawRect: will be executed )

-(IBAction)buttonPush:(UIButton *)sender
{
    ...
    [mySubView setNeedsDisplay];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM