Uiviewcontroller and UIView
Self.view-UIView: Root view
The UI on an interface is added to the Self.view, which is a direct or indirect sub-view of the Self.view.
Review: Window.rootviewcontroller
——————————————————————————————
Uiviewcontroller
View Controller
Role: Provides a basic property or method for managing the view of an application.
A view controller manages a set of views that make up a user interface. This includes loading, arranging views, interacting with views, and coordinating responses to data. In addition, interaction with other view controllers is also handled.
In general, an instance of Uiviewcontroller is not created directly, but it is a subclass of the instance session.
——————————————————————————————
Create UIView
Initialization
initWithFrame:
Basic properties:
. backgroundcolor
. Hidden//Is hidden
. Alpha//Transparency 0~1
. Layer
. clipstobounds
——————————————————————————————
The position and size of the. Frame//Current view relative to (direct) the parent view
. Bounds//Current view relative to its position and size
The location of the center//Current view's central point relative to the parent view
. Transform//deformation properties, changing view panning, scaling, rotation angle, etc.
——————————————————————————————
Identification of the. Tag//view
. userinteractionenable//Whether the view is allowed to receive user interaction, by default Yes
Method:
The hierarchy between views, by Addsubview: Make one view a child of another view. A view can have only one parent view, that is, when a view passes [Aview addsubview:],[bview Addsubview:], its parent view is bview.
Viewwithtag://Get View object by View identity
Addsubview://Add child view
Removefromsuperview//Child view detached from parent view
Bringsubviewtofront://move a child view to its parent view topmost
Insertsubview:atindex://Inserts a child view into the specified level index
Insertsubview:abovesubview://Inserts a child view over a child view
Insertsubview:belowsubview://Inserting a child view below a child view
Exchangesubviewatindex:withsubviewatindex://Swap the hierarchical index of two sub-views
——————————————————————————————
Adaptive between parent-child views
When the parent view is scaled, the position and size of the child view also changes.
Parent view. Autoresizessubviews//Set whether the child views can adapt to changes in the parent view
Child view. Autoresizingmask//Set child view to fit the parent view mode
——————————————————————————————
Layers of UIView: Calayer
Any view is composed of one master layer + multiple sublayers.
UIView object. Layer: is the primary layer
UIView drawing section is performed by Calayer, UIView is the manager of Calayer
——————————————————————————————
Animation
Animations in iOS are divided into two frames: UIKit and Quartz Core, respectively, on UIView and Calayer. The former is the encapsulation of the latter.
[Engineering]:uiviewanimation
A. UIView level animations (high package, simple code, low flexibility)
Set the value of the View property for a period of time, generally only need to set the start, the end value can be.
Method One and step:
+ Beginanimations:context://Start an animation block
+ setanimationduration://Set Animation duration
+ Setanimationdelay://Set Animation delay
+ Setanimationrepeatcount://Set Animation repeat Count
+ Setanimationcurve://Set animation curve style
+ SetAnimationTransition:forView:cache://Set transitions for the view during animation blocks
... This sets the view properties to be changed, such as frame
+ commitanimations//Submit an animation block
——————————————————————————————
Method Two: (Use block object)
+ animateWithDuration:delay:options:animations:completion://Use specified duration, delay, option, commit animation block, Animation complete block implementation animation; transform
[Engineering]: Calayeranimation
B. Calayer-level animations (direct manipulation of layers, code is slightly more complex, and highly flexible)
Implemented by Core Animation (kernel animation, CA), directly acting on calayer, for uiview level animations, the underlying is actually implemented by the CA.
Animation class under CA: Caanimation is the parent class of all animation classes and cannot be used directly, using its subclasses.
The subcategories that can be used are: Cabasicanimation, cakeyframeanimation, Caanimationgroup, Catransition.
>> catransition Creating animations
Methods and steps:
[Catransition Animation]//Create animated Object
Setduration://Duration of animation
SetType://Animation type
Setsubtype://Animation direction
. Layer Addanimation:forkey://Adding animated objects to layer Calayer
——————————————————————————————
IOS Development Learning User Interface (4) UIView and Uiviewcontroller "one"