iOS 개발 UIView 레이아웃 및 다시 그리기
카탈로그
배치
layoutSubviews
// UIView
- (void)layoutSubviews;
Subclasses can override this method as needed to perform more precise layout of their subviews, subviews
1: viewDidLoad(UIViewController)
2: frame change, addSubview UIScrollView
sub view frame change 및 화면을 회전할 때 부모view의layoutSubviews를 터치합니다
1: , setNeedsLayout layoutIfNeeded
2: You should override this method only if the autoresizing and constraint-based behaviors of the subviews do not offer the behavior you want
setNeedsLayout과layoutIfNeeded는 어떤 차이가 있습니까?setNeedsLayout은 태그만 다시 레이아웃해야 하지만 바로 갱신하지 않습니다.layoutIfNeeded와 함께 즉시 갱신할 수 있습니다
다시 그리다
drawRect
// UIView
- (void)drawRect:(CGRect)rect;
Draws the receiver’s image within the passed-in rectangle,
1: viewDidLoad(UIViewController)
2: setNeedsDisplay setNeedsDisplayInRect
1: , setNeedsDisplay setNeedsDisplayInRect
2: drawRect : rect 0