-
Drawing and printing:
-
drawRect:- Implement this method if your view draws custom content. If your view does not do any custom drawing, avoid overriding this method. -
drawRect:forViewPrintFormatter:- Implement this method only if you want to draw your view’s content differently during printing.
-
-
Layout:
-
sizeThatFits:- Implement this method if you want your view to have a different default size than it normally would during resizing operations. For example, you might use this method to prevent your view from shrinking to the point where subviews cannot be displayed correctly. -
layoutSubviews- Implement this method if you need more precise control over the layout of your subviews than the autoresizing behaviors provide. -
didAddSubview:,willRemoveSubview:- Implement these methods as needed to track the additions and removals of subviews. -
willMoveToSuperview:,didMoveToSuperview- Implement these methods as needed to track the movement of the current view in your view hierarchy. -
willMoveToWindow:,didMoveToWindow- Implement these methods as needed to track the movement of your view to a different window.
-
-
Event Handling:
-
touchesBegan:withEvent:,touchesMoved:withEvent:,touchesEnded:withEvent:,touchesCancelled:withEvent:- Implement these methods if you need to handle touch events directly. (For gesture-based input, use gesture recognizers.)
-
UIVIEW drawing content和layout的概念
最新推荐文章于 2021-09-01 21:58:08 发布
本文介绍了视图绘制与布局的基础方法,包括自定义绘制、打印处理、尺寸调整及子视图布局等核心技巧。此外还涉及触摸事件处理,帮助开发者更好地掌握视图管理。
1万+

被折叠的 条评论
为什么被折叠?



