UIWindow and UIview for IOS Learning

Source: Internet
Author: User

1. UIWindow:

1. There are three levels of UIWindowLevel:




Among them, the normal level is the lowest, but the statusBar, the highest level is alertView, alertView is generally used to interrupt user events. Print their values as 0.0000, 1000, and 2000 respectively.

2.-(CGPoint) convertPoint :( CGPoint) point toWindow :( UIWindow *) window; // can be used to convert to another window

-(CGPoint) convertPoint :( CGPoint) point fromWindow :( UIWindow *) window; // pass in nil to mean screen

-(CGRect) convertRect :( CGRect) rect toWindow :( UIWindow *) window;

-(CGRect) convertRect :( CGRect) rect fromWindow :( UIWindow *) window

Four Coordinate Transformations

3. the pop-up and hide notifications on the keyboard are in the UIWindow.

4. Operation Status Bar: Because stateBar is on the system Window and its level is UIWindowLevelStatusBar, we can create a Window level to overwrite Alert.

Ii. UIview:

1. animation curve attributes: Four

Typedef NS_ENUM (NSInteger, UIViewAnimationCurve ){

UIViewAnimationCurveEaseInOut, // slow at beginning and end

UIViewAnimationCurveEaseIn, // slow at beginning

UIViewAnimationCurveEaseOut, // slow at end



Set the animation curve in the animation playback process, such as fast first, slow, and linear.

2. animated transition: Flip up and down

Typedef NS_ENUM (NSInteger, UIViewAnimationTransition ){







3. Set the content mode:

Typedef NS_ENUM (NSInteger, UIViewContentMode ){

UIViewContentModeScaleToFill, // full control size, will stretch

UIViewContentModeScaleAspectFit, // scale proportionally until the length or width is the same as the size of the control.

UIViewContentModeScaleAspectFill, // scale according to the original proportion until the Minimum side is filled with the control, it will exceed the control

UIViewContentModeRedraw, // re-painting, will call setNeedDisplay, the same effect as the first one

UIViewContentModeCenter, // center, unchanged size

UIViewContentModeTop, // In the middle of the top, the size remains unchanged

UIViewContentModeBottom, // The middle of the bottom. The size remains unchanged. The following is similar








4. UIViewAutoresizingFlexibleLeftMargin automatically adjusts the distance between the left and the parent control, that is, the distance from the right of the parent control remains unchanged.

5. animation attributes:

Typedef NS_OPTIONS (NSUInteger, UIViewAnimationOptions ){

UIViewAnimationOptionLayoutSubviews = 1 <0, // animation of the Child Control

UIViewAnimationOptionAllowUserInteraction = 1 <1, // turn on user interaction while animating

UIViewAnimationOptionBeginFromCurrentState = 1 <2, // start all views from current value, not initial value

UIViewAnimationOptionRepeat = 1 <3, // repeat animation indefinitely duplicate

UIViewAnimationOptionAutoreverse = 1 <4, // if repeat, run animation back and forth upside down

UIViewAnimationOptionOverrideInheritedDuration = 1 <5, // ignore nested duration

UIViewAnimationOptionOverrideInheritedCurve = 1 <6, // ignore nested curve

UIViewAnimationOptionAllowAnimatedContent = 1 <7, // animate contents (applies to transitions only)

UIViewAnimationOptionShowHideTransitionViews = 1 <8, // flip to/from hidden state instead of adding/removing

UIViewAnimationOptionOverrideInheritedOptions = 1 <9, // do not inherit any options or animation type

UIViewAnimationOptionCurveEaseInOut = 0 <16, // default

UIViewAnimationOptionCurveEaseIn = 1 <16,

UIViewAnimationOptionCurveEaseOut = 2 <16,

UIViewAnimationOptionCurveLinear = 3 <16,

UIViewAnimationOptionTransitionNone = 0 <20, // default

UIViewAnimationOptionTransitionFlipFromLeft = 1 <20,

UIViewAnimationOptionTransitionFlipFromRight = 2 <20,

UIViewAnimationOptionTransitionCurlUp = 3 <20,

UIViewAnimationOptionTransitionCurlDown = 4 <20,

UIViewAnimationOptionTransitionCrossDissolve = 5 <20,

UIViewAnimationOptionTransitionFlipFromTop = 6 <20,

UIViewAnimationOptionTransitionFlipFromBottom = 7 <20,


Note: You can upload multiple parameters. You can use | or to upload multiple parameters.

UIViewAnimationOptionAllowUserInteraction) the animation is converted to (200,200,100,100). When the animation is executed, the image or button position has changed to (200,200,100,100). Therefore, you must click in (200,200,100,100) to make the animation effective, CLICKING In (100,100,) is invalid.

6.-(UIView *) hitTest :( CGPoint) point withEvent :( UIEvent *) event

HitTest: used to determine which sub-view to respond to events. The hidden control or a control with an alpha value less than 0.01 is invalid and will not call this function. This function will call-pointInside: withEvent: function recursively so that a control does not respond, you can override this function and return NO, so that even if the control's userInteractionEnabled is set to YES, it will not work.

HitTest principle: it distributes events to subviews one by one through-pointInside: withEvent. If YES is returned, the inheritance tree of the subview is traversed, check which sub-view will respond. If no response is returned, nil will be returned, self will be returned, and Recursion will end.

HitTest: withEvent :==> call pointInside: withEvent :==> (point function returns NO, end branch, return nil) // return YES ==> (the current view does not have subview, and hitTest returns self) // The current view has subviews ==> traverse from the top view of subviews, call hitTest: withEvent: recursively until hitTest returns the first non-nil object ==>( hitTest: withEvent :)

Events are distributed through UIApplication, which has an event queue.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.