189 8069 5689

UIView介绍-创新互联

1.什么是视图UIView介绍

   视图是屏幕上的一个矩形区域。它有两个用途:第一个用途是在上面绘制内容,第二个用途是处理事件。

创新互联专业为企业提供东宁网站建设、东宁做网站、东宁网站设计、东宁网站制作等企业网站建设、网页设计与制作、东宁企业网站模板建站服务,十年东宁做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

2.视图在iphone上是分层排列的,每个视图只有一个父视图,但有零个或多个子视图。

3.UIWindow是唯一没有父视图的视图,一个应用只有一个UIWindow。

4.操作视图层次的方法

  - (void)addSubView:(UIView *)view;

- (void)removeFromSuperview;

- (void)insertSubView:(UIView *)view atIndex:(int)index;

- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;

- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;

- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;

5.视图相关的结构体

 CGPoint   CGSize    CGRect

6.frame与bounds的区别

 frame是视图在其父视图坐标系统中的大小和位置

 bounds是视图在自身坐标系中的大小和位置

7.自定义视图,需要重写

- (void)drawRect:(CGRect)rect;

但永远不要直接调用上面的方法,而是调用下面的方法来通知系统重画视图

- (void)setNeedsDisplay;

8.处理事件的方法

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;

- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;


名称栏目:UIView介绍-创新互联
文章分享:http://cdxtjz.cn/article/deojph.html

其他资讯