2.2 Adding and Customizing Views This section focuses on two ways to add views: one is to use interface Builder, one to use code, and a custom view.
2.2.1 Using Interface Builder to add views using Interface Builder to add views is a fairly straightforward task. The following example will explain to the developer how to add a view using Interface Builder.
"Example 2-1"The following will add a view using Interface Builder, as follows:
(1) Create a single View application type of project, named 2-1.
(2) Open the Mainstoryboard.storyboard file and select the toolbar button on the far right of Xamarin studio to open the toolbar interface (view | pads| toolbar). Drag the View blank view object from the toolbar to the main display, as shown in 2.1.
Figure 2.1 Operation stepsNote: A blank view is added to the view at this point.
(3) Save the file (Command+s), click the "Run" button, the iOS simulator will appear at this time the results of the operation, 2.2 shows.
Figure 2.2 Running effectBecause the default background color of the view blank view added with Interface Builder is white, the effect is not visible on the emulator. So how do you see the added view blank views on the emulator? The developer needs to go back to the Mainstoryboard.storyboard file and select the view blank view object that is added on the main page. Then, select the Properties button on the far right of the Xamarin studio to open the Properties interface (View | Pads| " Properties command). Set the view's Background property to ScrollView textured Background color,2.3 as shown.
Figure 2.3 Operation stepNote: When you change the Background property, the color of the selected view object will also find a corresponding change. Run effect 2.4 as shown.
Figure 2.4 Running effectAt this point, you can see the added view on the iOS emulator. This example of ours has no effect. It just shows the developer how to add a view using Interface Builder.
Note: View blank view is most frequently used by developers for the following reasons:
(1) Each visual view object is inherited from the UIView class.
(2) provides automatic resizing function.
(3) UIView can manage content rendering.
(4) Since it is a container, you can accept other views as its child views.
(5) Touch events that can accept itself and its child views.
(6) Many of its properties can be animated.
Xamarin iOS Developer Manual-----2.2 Add and customize views