關於窗口和視圖html
In iOS, you use windows and views to present your application’s content on the screen. Windows do not have any visible content themselves but provide a basic container for your application’s views. Views define a portion of a window that you want to fill with some content. For example, you might have views that display images, text, shapes, or some combination thereof. You can also use views to organize and manage other views.ios
在iOS中,你使用窗口和視圖呈現應用程序裏的內容到屏幕上。 窗口自己沒有任何可視內容,只是給應用程序的視圖提供了一個基本容器。視圖定義了窗口的一部分,你能在視圖上放置一些內容。 好比,你可能有一些視圖,它們顯示圖片,文字,形狀或一些它們的組合。你還可使用視圖來組織和管理別的視圖。編程
Every application has at least one window and one view for presenting its content. UIKit and other system frameworks provide predefined views that you can use to present your content. These views range from simple buttons and text labels to more complex views such as table views, picker views, and scroll views. In places where the predefined views do not provide what you need, you can also define custom views and manage the drawing and event handling yourself.windows
任何一個應用都至少有一個窗口和一個視圖來顯示它的內容。 UIKit 以及其它系統框架提供了預約義的各類視圖來呈現你的內容。這些視圖包括不只簡單的按鈕和文本標籤,還包括複雜的視圖,好比表格視圖,選擇器視圖,滾動視圖等。若是預約義視圖不能知足你的需求,你還能夠自定義視圖並由你本身管理繪圖和事件處理。app
視圖管理應用程序中的可視內容框架
A view is an instance of the UIView
class (or one of its subclasses) and manages a rectangular area in your application window. Views are responsible for drawing content, handling multitouch events, and managing the layout of any subviews. Drawing involves using graphics technologies such as Core Graphics, OpenGL ES, or UIKit to draw shapes, images, and text inside a view’s rectangular area. A view responds to touch events in its rectangular area either by using gesture recognizers or by handling touch events directly. In the view hierarchy, parent views are responsible for positioning and sizing their child views and can do so dynamically. This ability to modify child views dynamically lets your views adjust to changing conditions, such as interface rotations and animations.ide
視圖是UIView類(或是它的子類)的一個實例,它管理應用程序窗口中一個矩形區域。 視圖負責繪製內容,處理多點觸摸事件,以及管理任何子視圖的佈局。繪圖涉及使用各類圖像技術,好比 Core Graphics, OpenGL ES, 或UIKit ,來繪製形狀,圖片,以及在視圖矩形區域內的文本。 視圖在它的矩形區域內對觸摸事件作出響應,經過手勢辨認或是直接處理觸摸事件。在視圖層次中, 父視圖負責給子視圖定位和定尺寸,並能動態的完成這些工做。 該動態修改子視圖的能力能讓視圖適應各類變化條件,好比界面轉動和動畫等。佈局
You can think of views as building blocks that you use to construct your user interface. Rather than use one view to present all of your content, you often use several views to build a view hierarchy. Each view in the hierarchy presents a particular portion of your user interface and is generally optimized for a specific type of content. For example, UIKit has views specifically for presenting images, text and other types of content.學習
你能夠把視圖想象成構建塊,你能夠用它們來構建你本身的接口。你一般會使用幾個視圖來創建一個視圖層次,而不是把全部的內容都放置在一個視圖裏。 層次裏的每一個視圖都表明用戶界面的一部分, 並且通常是一種特定類型的內容。 好比,UIKit 框架有分別用來表明圖像,文本以及其它類型內容的視圖。flex
窗口定位各類視圖的顯示
A window is an instance of the UIWindow
class and handles the overall presentation of your application’s user interface. Windows work with views (and their owning view controllers) to manage interactions with, and changes to, the visible view hierarchy. For the most part, your application’s window never changes. After the window is created, it stays the same and only the views displayed by it change. Every application has at least one window that displays the application’s user interface on a device’s main screen. If an external display is connected to the device, applications can create a second window to present content on that screen as well.
窗口是UIWindow 類的一個實例,它處理整個應用程序用戶界面的外觀。窗口跟視圖(以及它們擁有的視圖控制器)一塊兒工做,來管理可見視圖層次的交互及轉換。大多數狀況下,應用程序的窗口永遠不會改變。 當窗口被建立了以後,它就一直保持不變,只有視圖會根據變化顯示不一樣的視圖。 任何應用程序都至少有一個窗口,它在設備的主屏幕上顯示應用程序的用戶界面。 若是有外部顯示被鏈接到設備,應用程序也能在屏幕上建立第二個窗口來呈現內容。
動畫在界面發生改變時給用戶提供可見的反饋
Animations provide users with visible feedback about changes to your view hierarchy. The system defines standard animations for presenting modal views and transitioning between different groups of views. However, many attributes of a view can also be animated directly. For example, through animation you can change the transparency of a view, its position on the screen, its size, its background color, or other attributes. And if you work directly with the view’s underlying Core Animation layer object, you can perform many other animations as well.
動畫給用戶提供可見的反饋,這些反饋關於視圖層次上的各類改變。系統定義了標準動畫來呈現模型視圖以及不一樣視圖組之間的轉換。 然而, 不少視圖的屬性也能直接被動畫。好比,經過動畫你能夠改變視圖的透明度, 它在屏幕上的位置,尺寸,背景顏色或其它屬性。 並且若是你直接用視圖的相關核心動畫(Core Animation)層對象工做,你還能夠執行不少其它動畫。
界面生成器
Interface Builder is an application that you use to graphically construct and configure your application’s windows and views. Using Interface Builder, you assemble your views and place them in a nib file, which is a resource file that stores a freeze-dried version of your views and other objects. When you load a nib file at runtime, the objects inside it are reconstituted into actual objects that your code can then manipulate programmatically.
界面生成器是用來圖形化構造和配置應用程序窗口和視圖的應用。 使用界面生成器,你組合各類視圖,並把它們放在一個nib文件中。nib 文件是一個資源文件,它用來存儲視圖的凍幹(freeze-dried)版本以及其它對象。當你在運行時載入一個nib文件時,文件裏的全部對象被改組爲實際的對象,而後你的代碼能對這些對象進行編程操做。
Interface Builder greatly simplifies the work you have to do in creating your application’s user interface. Because support for Interface Builder and nib files is incorporated throughout iOS, little effort is required to incorporate nib files into your application’s design.
界面生成器大大簡化了建立應用程序用戶界面時你不得不作的工做。 由於整個iOS都支持界面生成器和nib文件,你只須要一點努力就能夠把nib文件組合到應用程序設計中去。
For more information about how to use Interface Builder, see Interface Builder User Guide. For information about how view controllers manage the nib files containing their views, see 「Custom View Controllers」 in View Controller Programming Guide for iOS.
要想了解更多有關使用界面生成器的信息,查看《Interface Builder User Guide--界面生成器使用指南》。有關視圖控制器如何管理包含各類視圖的nib文件的詳細信息,查看「Custom View Controllers」 in View Controller Programming Guide for iOS.
Because views are very sophisticated and flexible objects, it would be impossible to cover all of their behaviors in one document. However, other documents are available to help you learn about other aspects of managing views and your user interface as a whole.
由於視圖是一些很是複雜和靈活的對象,不可能在一個文檔裏所有講述它們。 然而,其它文檔能幫助你全面學習有關管理視圖的其它方面,以及整個用戶界面。
View controllers are an important part of managing your application’s views. A view controller presides over all of the views in a single view hierarchy and facilitates the presentation of those views on the screen. For more information about view controllers and the role they play, see View Controller Programming Guide for iOS.
視圖控制器是管理應用程序視圖的重要一部分。 一個視圖控制器管理着一個視圖層次裏的全部視圖,並讓這些視圖的外觀顯示在屏幕上。 關於更多視圖控制器的信息以及它們所扮演的角色,請查看 View Controller Programming Guide for iOS.
Views are the key recipients of gesture and touch events in your application. For more information about using gesture recognizers and handling touch events directly, see Event Handling Guide for iOS.
視圖是應用程序中手勢和觸摸事件的主要接收者。更多關於使用手勢辨認器和直接處理觸摸事件的信息,請看Event Handling Guide for iOS.
Custom views must use the available drawing technologies to render their content. For information about using these technologies to draw within your views, see Drawing and Printing Guide for iOS.
自定義視圖必須使用可行的繪製技術,用來呈現它們的內容。 關於用來在視圖裏繪製的這些技術,請看Drawing and Printing Guide for iOS.
In places where the standard view animations are not sufficient, you can use Core Animation. For information about implementing animations using Core Animation, see Core Animation Programming Guide.
當標準視圖動畫沒有效果時,你可使用內核動畫。 關於用內核動畫實現動畫的信息,請看 Core Animation Programming Guide.