All right, I'll go on, let's start our exploration of UIView instance method
UIViewExample Method Instance Methods
Initialize a view
-(ID) initWithFrame: (cgrect) Arect//Initialize a View object with the specified frame
edit State in the end view
-(BOOL) Endediting: (BOOL) force
This is especially useful when bouncing back to the keyboard.
about Responses
-(void) Addgesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer
Add a gesture recognizer to a view
-(void) Removegesturerecognizer: (Uigesturerecognizer *) Gesturerecognizer
Remove a gesture recognizer
-(BOOL) Gesturerecognizershouldbegin: (Uigesturerecognizer *) Gesturerecognizer
Start a gesture recognizer
-(void) Addmotioneffect: (Uimotioneffect *) effect
Start adding a motion effect to the view, so it's actually blurry, for example, the warning box will tilt as the phone tilts,
Of course this requires code implementation, but we can now detect the mobile phone's motion events to respond accordingly
Start using from IOS7
Manage view hierarchies managing the View Hierarchy
-(void) Addsubview: (UIView *) View//Add sub-view
-(void) Removefromsuperview//removal from parent view
-(void) Bringsubviewtofront: (UIView *) view
Move the specified sub-view to the top level
-(void) Sendsubviewtoback: (UIView *) view
Move the developed sub-view to the rear, under all child views
-(void) Insertsubview: (UIView *) View Atindex: (nsinteger) index
Inserts a child view at the specified location, and all views of the view actually make up an array
-(void) Insertsubview: (UIView *) View Abovesubview: (UIView *) Siblingsubview
Moves the specified child view to the front of the specified Siblingsubview child view
-(void) Insertsubview: (UIView *) View Belowsubview: (UIView *) Siblingsubview
Moves the specified child view to the back of the specified Siblingsubview child view
-(void) Exchangesubviewatindex: (Nsinteger) index1 Withsubviewatindex: (Nsinteger) Index2
Swap the locations of two sub-views
-(BOOL) Isdescendantofview: (UIView *) view
Determines whether the receiving object is a child view of the specified view, or the same view as the specified view
Configure automatic sizing status configuring the resizing Behavior
-(void) SizeToFit//depending on the size position of the child view, adjust the view so that it happens to surround the child view,
That is, the size of the child view is automatically adjusted to show only the child view
-(Cgsize) Sizethatfits: (cgsize) size
Make the view calculation most suitable for the size of the child view, which is the smallest size required to display all the child views
laying sub-view laying out subviews
-(void) layoutsubviews//sketch child view
-(void) layoutifneeded//immediately sketch child view
-(void) setneedslayout
Invalidates the layout of the current receiving object and triggers a new layout in the next update cycle
choose to join constraint-based layouts opting in to constraint-based layout
-(void) Settranslatesautoresizingmaskintoconstraints: (BOOL) flag
Sets whether the mask automatically adjusts dimensions to constraints based on constrained layouts
-(BOOL) translatesautoresizingmaskintoconstraints
Determines whether the view will automatically resize the mask to convert to constrained layout-based constraints
Administrative constraints Managing Constraints
-(Nsarray *) constraints//Return constraints created by the view
-(void) AddConstraint: (Nslayoutconstraint *) constraint
Add a constraint for a view layout or a child view, and the constraint constraint can only be within the current view, including the child view
-(void) Addconstraints: (Nsarray *) constraints
Add a set of constraints
-(void) Removeconstraint: (Nslayoutconstraint *) constraint
To remove a specified constraint on a view
-(void) Removeconstraints: (Nsarray *) constraints
Removes a specified set of constraints
measuring measuring in constraint-based layout based on constrained layouts
-(Cgsize) Systemlayoutsizefittingsize: (cgsize) targetsize
Returns the size of the view that satisfies the hold constraint
-(Cgsize) intrinsiccontentsize
Returns the original size of the receiving object
-(void) invalidateintrinsiccontentsize
To revoke the size of the view's original content
-(Uilayoutpriority) Contentcompressionresistancepriorityforaxis: (uilayoutconstraintaxis) axis
Sets how the view's compression changes when the view becomes small, whether it shrinks horizontally or vertically, and returns a priority
-(void) Setcontentcompressionresistancepriority: (uilayoutpriority) Priority foraxis: (uilayoutconstraintaxis) axis
Set Priority
-(Uilayoutpriority) Contenthuggingpriorityforaxis: (uilayoutconstraintaxis) axis
The opposite of the top is the way the view zooms in.
-(void) Setcontenthuggingpriority: (uilayoutpriority) Priority foraxis: (uilayoutconstraintaxis) axis
Refer to the method above
Calibration View aligning views with constraint-based Layout
-(CGRect) Alignmentrectforframe: (CGRect) frame
Returns the alignment matrix for a view of a given frame
-(CGRect) Frameforalignmentrect: (CGRect) Alignmentrect
Frame that returns the view of the given alignment rectangle
-(Uiedgeinsets) alignmentrectinsets
Returns the bounding rectangle of the alignment matrix defined from the view's frame
-(UIView *) viewforbaselinelayout
Returns a view that satisfies the baseline constraint condition
triggering constraint-based layouts triggering constraint-based layout
-(BOOL) needsupdateconstraints//View constraints need to be updated
-(void) setneedsupdateconstraints//Set constraints on the view need to be updated
-(void) updateconstraints//update constraint for view
-(void) updateconstraintsifneeded//Update the constraints of the view and its child views
debugging constraint-based layouts debugging constraint-based layout
-(Nsarray *) Constraintsaffectinglayoutforaxis: (uilayoutconstraintaxis) axis
Returns a constraint that affects the layout of a given axis view
-(BOOL) hasambiguouslayout//whether the position of the view is not fully specified
-(void) exerciseambiguityinlayout
Randomly change the frame of a view between different valid values with a fuzzy layout
Painting and updating views Drawing and Updating the view
-(void) DrawRect: (cgrect) rect//Painting view in the specified area
-(void) Setneedsdisplay//mark the bounding rectangle of the entire view needs to be redrawn
-(void) Setneedsdisplayinrect: (CGRect) Invalidrect
Marking the boundaries of a view within a specified range requires redrawing
Format Print View content
-(Uiviewprintformatter *) Viewprintformatter//Return to the print format of the view
-(void) DrawRect: (cgrect) area forviewprintformatter: (Uiviewprintformatter *) formatter
Specify area and print format painting view content
Save and restore status preserving and Restoring state
-(void) Encoderestorablestatewithcoder: (Nscoder *) coder
Status information for encoded views
-(void) Decoderestorablestatewithcoder: (Nscoder *) coder
Decode a view state information
Tag View
-(UIView *) Viewwithtag: (Nsinteger) tag
Convert view coordinates converting between view coordinate Systems
-(Cgpoint) Convertpoint: (cgpoint) point toview: (UIView *) view
Convert a point from the coordinate system of the receiving object to the specified view
-(Cgpoint) Convertpoint: (cgpoint) point fromview: (UIView *) view
In contrast to the above, a point in the specified view coordinates is converted to the receiving object
-(CGRect) Convertrect: (cgrect) rect toview: (UIView *) view
-(CGRect) Convertrect: (cgrect) rect fromview: (UIView *) view
Refer to the above two methods
Click Test in the View
-(UIView *) HitTest: (cgpoint) point withevent: (Uievent *) event
Click Test to specify the event at the specified point
-(BOOL) Pointinside: (cgpoint) point withevent: (Uievent *) event
Tests whether the specified point is contained in the receiving object
Note the changes associated with the view observing view-related changes
-(void) Didaddsubview: (UIView *) Subview
The notification view specifies that the child view has been added
-(void) Willremovesubview: (UIView *) Subview
Notifies the view that the specified child view will be removed
-(void) Willmovetosuperview: (UIView *) Newsuperview
Notifies the view that it will be moved to a new parent view
-(void) Didmovetosuperview
The notification view has moved to a new parent view
-(void) Willmovetowindow: (UIWindow *) NewWindow
The notification view is going to be moved to a new window
-(void) Didmovetowindow
The notification view has been moved to a new window
The above is the UIView class instance method, more, I follow the document to divide it into several categories.
So far this class has almost been known, as I expected, to know
There is something in this class that will not take many detours in the future.
UIView instance Method Instance Methods (RPM)