IOS开发之UI设计---UIView深入

UIView : NSObject 

frame center bounds 

frame 相对于父视图

center  相对于父视图  (CGPoint)point;

bounds 相对于视图本身

 

//设置viewcenter属性

- (void)setCenter:(CGPoint)point;//设置viewcenter属性,会改变视图的frame

- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index;//在父视图上添加一个子视图,index为子视图在父视图上所处的位置,0开始.

- (void)exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2;//交换父视图上指定位置的两个子视图的位置

- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview;//在某个子视图的下面添加一个新的子视图,即新添加的视图会被siblingSubview覆盖

- (void)insertSubview:(UIView *)view aboveSubview:(UIView *)siblingSubview;//在某个子视图上面添加一个新的子视图,即新添加的子视图会覆盖siblingSubview视图

 

//clipsToBounds:调用主体是父视图,如下所示,view2超过view1的边界部分,会被自动剪裁掉

view1.clipsToBounds = YES;

[view1 addSubview:view2];

   [view2 release];

 

//view设置动画效果

   [UIViewbeginAnimations:nilcontext:nil];

   [UIViewsetAnimationDuration:0.5];//设置动画时间

   [UIViewsetAnimationTransition:arc4random()%5forView:view cache:YES];//设置动画效果随机

//UIView做操作

   [UIViewcommitAnimations];//提交动画

 

//view从父视图中移除

[view removeFromSuperview];

    [view release];

removeFromSuperview:解除view在某个窗口中的关系链,同时将view从其父视图中移除,但是view的引用计数不会减1,所以需要在调用removeFromSuperview方法后将其引用计数减一,防止内存泄露.

- (BOOL)isDescendantOfView:(UIView *)view;//判断某个视图是否是view的子视图

//Returns a Boolean value indicating whether the receiver is a subview of a given view or identical to that view.

 

 

 

 

 

 

posted @ 2013-06-30 10:55  站在巨人肩膀上看巨人  阅读(279)  评论(0)    收藏  举报