UIView实例创建方法:
UIView重绘方法:
1、 重新实现drawRect:完用户自定义的绘图工作 (注:当使用OpenGL ES时,drawRect:失效;另一个重绘函数drawRect:forViewPrintFormatter:不是很了解);
2、 调用setNeedsDisplay或setNeedsDisplayInRect: 向系统发出重绘消息,当系统到达重绘周期调用drawRect:实现视图重绘工作;
UIView属性:
@property frame; //CGRect View在SuperView坐标系的位置和大小
@property bounds; //CGRect View本身的位置和大小(View自己的坐标系)
@property center; // CGPoint View在SuperView坐标系的中心位置
@property transform; // CGAffineTransform 仿射参数(受autoresizingMask影响)
@property alpha; //CGFloat View透明度range[0.0, 1.0]
@property backgroundColor; //UIColor View背景颜色
@property opaque; //BOOL YES-不透明,NO-根据alpha决定透明度;
@property contentMode //UIViewContentMode SuperView大小变化View变化方式
可reimplement实现方法:
layoutSubviews View需要重新布局时系统自动调用(setNeedsLayout可以实现调用)。下面几个一看就知道什么时候系统调用:
didAddSubview:
willRemoveSubview
willMoveToSuperview:
didMoveToSuperview
willMoveToWindow
didMoveToWindow触摸事件函数:
toucherBegan:withEvent:
touchesMoved:withEvent:
touchesEnded:withEvent:
touchesCancelled:withEvent:
(注:当使用addGestureRecognizer:initWithTarge:taction:添加了GestureRecognizer的识别实例touchesMoved:withEvent和touchesEnded:withEvent可能不发生);
gestureRecognizerShouldBegin: