UIView

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:
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值