UIView 객체가 생성될 때 뷰들이 준비(viewDidLoad)되고 난뒤 그려줄 때 DrawRect가 불려진다.
화면에 그려주고 싶은게 있으면 보통 DrawRect에서 그려주는데, setNeedsDisplay로 DrawRect가 다시 불릴 수 있도록 이벤트를 던질 수 있다.
다만, Event Driven형식으로 동작하는 iOS에서는 setNeedsDisplay를 사용하면 즉시 drawRect가 동작되지 않는다. 이 녀석은 다시 그려야 할 것이 있다는 Flag만 설정 해 주고, 다음 실행 루프에서 drawRect가 동작하게 된다.

* setNeedsDisplay
Marks the receiver’s entire bounds rectangle as needing to be redrawn.
Discussion
You can use this method or the setNeedsDisplayInRect: to notify the system that your view’s contents need to be redrawn. This method makes a note of the request and returns immediately. The view is not actually redrawn until the next drawing cycle, at which point all invalidated views are updated.
  출처 : Apple Document.

* setNeedsDisplay:
Controls whether the receiver's entire bounds rectangle is marked as needing display.
- (void)setNeedsDisplay
Description
By default, geometry changes to a view automatically redisplays the view without needing to invoke the drawRect: method. Therefore, you need to request that a view redraw only when the data or state used for drawing a view changes. In this case, send the view the setNeedsDisplay message. Any UIView objects marked as needing display are automatically redisplayed when the application returns to the run loop.
  출처 :
http://www.picksourcecode.com/ps/ct/16683.php
Posted by 프리지크
:
BLOG main image
인생에서는 찾고, 노력하고, 희생할 각오가 되어 있는 것만 얻을 수 있다. (조시 매슈 애덤스) by 프리지크

공지사항

카테고리

분류 전체보기 (121)
끄적끄적 (16)
좋은 글 (9)
자료 (19)
런닝&피트니스 (18)
기술 (43)
기사 스크랩 (1)
내가 본 공연 후기 (1)
내가 가 본 맛집 (5)
괜찮아 보이는 펜션들 (4)
(4)
한장한장 (0)
비공개 스크랩 (0)

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

Total :
Today : Yesterday :