zoukankan      html  css  js  c++  java
  • android 和iOS的view上的区别

    android上的view的类叫View,

    以下是它的class overview,

    This class represents the basic building block for user interface components. A View occupies a rectangular area on the screen and is responsible for drawing and event handling. View is the base class for widgets, which are used to create interactive UI components (buttons, text fields, etc.). The  ViewGroup subclass is the base class for layouts, which are invisible containers that hold other Views (or other ViewGroups) and define their layout properties.

    根据以上说明,可以看出,ViewGroup类才能添加子view,View类本身不提供添加子view的功能。

    ios上的view的类叫UIView,

    以下是它的class overview,

    The UIView class defines a rectangular area on the screen and the interfaces for managing the content in that area. At runtime, a view object handles the rendering of any content in its area and also handles any interactions with that content. The UIView class itself provides basic behavior for filling its rectangular area with a background color. More sophisticated content can be presented by subclassing UIView and implementing the necessary drawing and event-handling code yourself. The UIKit framework also includes a set of standard subclasses that range from simple buttons to complex tables and can be used as-is. For example, a UILabel object draws a text string and a UIImageView object draws an image.

    Because view objects are the main way your application interacts with the user, they have a number of responsibilities. Here are just a few:

    • Drawing and animation

      • Views draw content in their rectangular area using technologies such as UIKit, Core Graphics, and OpenGL ES.

      • Some view properties can be animated to new values.

    • Layout and subview management

      • A view may contain zero or more subviews.

      • Each view defines its own default resizing behavior in relation to its parent view.

      • A view can define the size and position of its subviews as needed.

    • Event handling

      • A view is a responder and can handle touch events and other events defined by the UIResponder class.

      • Views can use the addGestureRecognizer: method to install gesture recognizers to handle common gestures.

    Views can embed other views and create sophisticated visual hierarchies. This creates a parent-child relationship between the view being embedded (known as the subview) and the parent view doing the embedding (known as the superview). Normally, a subview’s visible area is not clipped to the bounds of its superview, but in iOS you can use the clipsToBounds property to alter that behavior. A parent view may contain any number of subviews but each subview has only one superview, which is responsible for positioning its subviews appropriately.

    根据以上说明,iso的view具有添加subView的功能。

    仔细对比阅读以上overview,可以更加明确它们之间的区别。

  • 相关阅读:
    【转】Android开发——MediaProvider源码分析(2)
    关于ActivityGroup使用过程中遇到的一点问题
    HttpWebRequest详解
    关于Assembly.CreateInstance()与Activator.CreateInstance()方法的区别
    你会在C#的类库中添加web service引用吗?
    ASP.NET跳转网页的三种方法的比较
    .net发送HTTP POST包
    依赖注入
    微软ASP.NET MVC Beta版本发布
    随笔~
  • 原文地址:https://www.cnblogs.com/breezemist/p/3350262.html
Copyright © 2011-2022 走看看