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.

     

     

     

     

     

     

  • 相关阅读:
    优雅的windowsC++项目的配置
    C++实现编码转换
    C++读取配置文件
    完全依赖QML实现播放器
    记一次和“N+1”的擦肩而过
    FFmpeg4.0笔记:采集系统声音
    FFmpeg4.0笔记:采集桌面
    FFmpeg4.0笔记:封装ffmpeg的解封装功能类CDemux
    SDL2:封装媒体显示播放Csdl2
    FFmpeg4.0笔记:封装ffmpeg的音频重采样功能类CSwr
  • 原文地址:https://www.cnblogs.com/my_work_blog_space/p/3163382.html
Copyright © 2011-2022 走看看