简体   繁体   中英

How to call -(void)drawRect:(CGRect)rect

How Can i Call

-(void)drawRect:(CGRect)rect

in https://github.com/stkim1/MTImageMapView/blob/master/MTImageMapView/MTImageMapView.m

From Another UiViewController Periodically With NSTimer

From the documentation :

Discussion

The default implementation of this method does nothing. Subclasses that use technologies such as Core Graphics and UIKit to draw their view's content should override this method and implement their drawing code there. You do not need to override this method if your view sets its content in other ways. For example, you do not need to override this method if your view just displays a background color or if your view sets its content directly using the underlying layer object.

...

If you subclass UIView directly, your implementation of this method does not need to call super. However, if you are subclassing a different view class, you should call super at some point in your implementation.

This method is called when a view is first displayed or when an event occurs that invalidates a visible part of the view. You should never call this method directly yourself . To invalidate part of your view, and thus cause that portion to be redrawn, call the setNeedsDisplay or setNeedsDisplayInRect: method instead.

是的,我找到了解决方案,我在drawrect函数的末尾调用了一个带有计时器的函数,并在其中调用了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