티스토리 뷰

반응형

UIView에 관해 많이 까먹어서 옛날에 들었던 Stanford iOS 강의 중 View 부분을 다시 듣고 있는데, 까먹지 않게 정리 중 --! 

 

 

[1] bounds가 change되면 다시 draw를 하는가?! 

 


* 예제로 보여주신 것 

이렇게 뷰를 만드셨고,

돌려보면 이렇게 나옵니다

 


- 기본 설정에서 (contenMode가 scaleToFill..!!) rotate할 때 

 

 

- 이렇게 contentMode를 Redraw로 바꾸고 rotate할 때 

   => 이렇게 설정하면 bounds가 change 될때, drawRect을 다시 부르게 됩니다 

 

 





이 내용 관련 정말 정리 잘한 블로그!
https://useyourloaf.com/blog/stretching-redrawing-and-positioning-with-contentmode/

 

Stretching, Redrawing and Positioning with contentMode

The contentMode property of UIView allows you to control how to layout a view when the view’s bounds change. The system will not, by default, redraw a view each time the bounds change. That would be wasteful. Instead, depending on the content mode, it can

useyourloaf.com




[2] UIView의 이니셜라이저와 awakeFromNib 

 

 

[3] CustomView 만들기 

 

 

 

 

 

** 나중에 해보기 (clip과 intersect관해서) ** 

 

반응형
댓글