zoukankan      html  css  js  c++  java
  • iPhone 的 UIView的学习

    NSObject

             UIResponder

                         UIView

                              UIWindow

                              UILabel

                              UIPickerView

                              UIProgressView

                              UIImageView

                              UITabBar

                              UIToolBar

                              UINavigateBar

                              UITableViewCell

                              UIActionSheet

                              UIAlertView

                              UIScrollView --UITableView,UITextView

                              UISearchBar

                              UIWebView

                              UIControl

                                        UIButton

                                        UIDatePicker

                                        UIPageControl

                                        UISegmentedControl

                                        UITextField

                                        UISlider

                                        UISwith 

                               

    概述

    UIView对象在屏幕中定义了一个复杂区域和界面来管理这个区域的内容

    视图的职责:
    画图和动画。
    布局和子视图管理。

    事件处理。

     

    1、创建一个视图对象

    CGRect viewRect = CGRectMake(10,10,100,100);
    UIView* myView = [[UIView alloc] initWithFrame:viewRect];
    [self.window addSubview :myView];//将视图作为子视图添加到window中

    2、动画

    改变一些视图属性将会使用到动画,改变属性时创建一个动画,用于给用户传递在较短时间内的变化。UIView类做了动画展现的大部分工作,但是你仍然需要声明哪种属性改变的时候,你需要动画效果。有两种不同的类型来初始化动画
    下面的UIView属性支持动画:
    frame,bounds,center,transform,alpha,backgroundColor,contentStretch
    在iOS 4之后,使用block-based动画方法(推荐使用)
    使用 开始/提交方式(begin/commit)

    3、管理视图的层次结构

    superview属性:
    subviews属性:
    window属性:
    -addSubview方法
    -bringSubviewToFront:(UIView *)veiw方法,将view视图移到层次结构的最顶端,使得其得以展示
    -sendSubviewToBack:(UIView *)veiw方法,和上面方法正好相反
    -removeFromSupview方法,
    -insertSubview:(UIView *)view atIndex:(Interger)index方法
    -insertSubview:(UIView *)view aboveSubview(UIView *)siblingView 方法
    -insertSubview:(UIView *)view belowSubview(UIView *)siblingView 方法
    -exchangeSubviewAtIndex:(NSInteger)index1 withSubviewAtIndex:(NSInteger)index2方法
    -isDescendantOfView:(UIView *)view方法,判断view是不是指定视图的子视图

    4、子视图的布局(layout)

    -layoutSubviews方法,这个方法,默认没有做任何事情,需要子类进行重写
    -setNeedsLayout方法
    -layoutIfNeeded方法,立即对子视图进行布局

    5、画/更新视图

    -drawRect:(CGRect)rect方法
    -setNeedsDisplay
    -setNeedsDisplayInRect:(CGRect)invalidRect方法

    6、以块展现动画的方式(animating views with block)

    + animateWithDuration:delay:options:animations:completion:
    + animateWithDuration:animations:completion:
    + animateWithDuration:animations:
    + transitionWithView:duration:options:animations:completion:

    + transitionFromView:toView:duration:options:completion:

    7、在视图和坐标系统之间转换

    -convertPoint:toView
    -convetPoint:fromView
    -convertRect:toView
    -convertRect:fromView

    8、跟踪视图相关的改变

    -didAddSubview:
    -willRemoveSubview:
    -willMoveToSuperview
    -didMoveToSuperview
    -willMoveToWindow:

    -didMoveToWindow 

  • 相关阅读:
    VS10的一个问题
    有关开发的配置的有用信息
    管理Fragments(转)
    消除SDK更新时的“https://dl-ssl.google.com refused”异常--(转)
    JAVA字符串编码转换常用类
    在 Android 中调用二进制可执行程序(native executable )
    Android NDK 下的宽字符编码转换及icu库的使用(转)
    Linux字符编码转换 UTF8转GB3212
    一键生成JNI头文件方法二
    eclipse中创建NDK和JNI开发环境最简单配置方法
  • 原文地址:https://www.cnblogs.com/csj007523/p/2650927.html
Copyright © 2011-2022 走看看