zoukankan      html  css  js  c++  java
  • 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.

     

     

     

     

     

     

  • 相关阅读:
    运营活动总结
    《天天来塔防》游戏分析
    C++ 头文件与using namespace std
    cocos2dx -- 错误笔记(4)ntdll.dll堆已损坏
    大学,且行且珍惜
    cocos2dx -- 错误笔记(3)class类型重定义
    谈谈对HTML语义化的理解
    CSS深入研究:display的恐怖故事解密(2)
    We have a problem with promises
    react-组件生命周期
  • 原文地址:https://www.cnblogs.com/my_work_blog_space/p/3163382.html
Copyright © 2011-2022 走看看