Class: UIView

Inherits:
UIResponder show all

Overview

The UIView class defines a rectangular area on the screen and the interfaces for managing the content in that area. At runtime, a view object handles the rendering of any content in its area and also handles any interactions with that content. The UIView class itself provides basic behavior for filling its rectangular area with a background color. More sophisticated content can be presented by subclassing UIView and implementing the necessary drawing and event-handling code yourself. The UIKit framework also includes a set of standard subclasses that range from simple buttons to complex tables and can be used as-is. For example, a UILabel object draws a text string and a UIImageView object draws an image.

Direct Known Subclasses

ADBannerView, MKAnnotationView, MKMapView, MKOverlayView, MPVolumeView, UIActionSheet, UIActivityIndicatorView, UIAlertView, UICollectionReusableView, UIControl, UIImageView, UILabel, UINavigationBar, UIPickerView, UIPopoverBackgroundView, UIProgressView, UIScrollView, UISearchBar, UITabBar, UITableViewCell, UITableViewHeaderFooterView, UIToolbar, UIWebView, UIWindow

Instance Attribute Summary (collapse)

Attributes inherited from UIResponder

#inputAccessoryView, #inputView, #undoManager

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from UIResponder

#becomeFirstResponder, #canBecomeFirstResponder, #canPerformAction:withSender:, #canResignFirstResponder, #isFirstResponder, #motionBegan:withEvent:, #motionCancelled:withEvent:, #motionEnded:withEvent:, #nextResponder, #reloadInputViews, #remoteControlReceivedWithEvent:, #resignFirstResponder, #touchesBegan:withEvent:, #touchesCancelled:withEvent:, #touchesEnded:withEvent:, #touchesMoved:withEvent:

Methods inherited from NSObject

#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version

Constructor Details

This class inherits a constructor from NSObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class NSObject

Instance Attribute Details

- (Float) alpha

The receiver’s alpha value. The value of this property is a floating-point number in the range 0.0 to 1.0, where 0.0 represents totally transparent and 1.0 represents totally opaque. This value affects only the current view and does not affect any of its embedded subviews.Changes to this property can be animated.

Returns:

- (Boolean) autoresizesSubviews

A Boolean value that determines whether the receiver automatically resizes its subviews when its bounds change. When set to YES, the receiver adjusts the size of its subviews when its bounds change. The default value is YES.

Returns:

  • (Boolean)

- (UIViewAutoresizing) autoresizingMask

An integer bit mask that determines how the receiver resizes itself when its superview’s bounds change. When a view’s bounds change, that view automatically resizes its subviews according to each subview’s autoresizing mask. You specify the value of this mask by combining the constants described in UIViewAutoresizing using the C bitwise OR operator. Combining these constants lets you specify which dimensions of the view should grow or shrink relative to the superview. The default value of this property is UIViewAutoresizingNone, which indicates that the view should not be resized at all. When more than one option along the same axis is set, the default behavior is to distribute the size difference proportionally among the flexible portions. The larger the flexible portion, relative to the other flexible portions, the more it is likely to grow. For example, suppose this property includes the UIViewAutoresizingFlexibleWidth and UIViewAutoresizingFlexibleRightMargin constants but does not include the UIViewAutoresizingFlexibleLeftMargin constant, thus indicating that the width of the view’s left margin is fixed but that the view’s width and right margin may change. Thus, the view appears anchored to the left side of its superview while both the view width and the gap to the right of the view increase.If the autoresizing behaviors do not offer the precise layout that you need for your views, you can use a custom container view and override its layoutSubviews method to position your subviews more precisely.

Returns:

  • (UIViewAutoresizing)

- (UIColor) backgroundColor

The receiver’s background color. Changes to this property can be animated. The default value is nil, which results in a transparent background color.

Returns:

- (CGRect) bounds

The bounds rectangle, which describes the view’s location and size in its own coordinate system. On the screen, the bounds rectangle represents the same visible portion of the view as its frame rectangle. By default, the origin of the bounds rectangle is set to (0, 0) but you can change this value to display different portions of the view. The size of the bounds rectangle is coupled to the size of the frame rectangle, so that changes to one affect the other. Changing the bounds size grows or shrinks the view relative to its center point. The coordinates of the bounds rectangle are always specified in points.Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw. Changes to this property can be animated. The default bounds origin is (0,0) and the size is the same as the frame rectangle’s size.

Returns:

- (CGPoint) center

The center of the frame. The center is specified within the coordinate system of its superview and is measured in points. Setting this property changes the values of the frame properties accordingly.Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw. Changes to this property can be animated. Use the beginAnimations:context: class method to begin and the commitAnimations class method to end an animation block.

Returns:

  • (CGPoint)

- (Boolean) clearsContextBeforeDrawing

A Boolean value that determines whether the receiver’s bounds should be automatically cleared before drawing. When set to YES, the drawing buffer is automatically cleared to transparent black before the drawRect: method is called. This behavior ensures that there are no visual artifacts left over when the view’s contents are redrawn. If the view’s opaque property is also set to YES, the backgroundColor property of the view must not be nil or drawing errors may occur. The default value of this property is YES.If you set the value of this property to NO, you are responsible for ensuring the contents of the view are drawn properly in your drawRect: method. If your drawing code is already heavily optimized, setting this property is NO can improve performance, especially during scrolling when only a portion of the view might need to be redrawn.

Returns:

  • (Boolean)

- (Boolean) clipsToBounds

A Boolean value that determines whether subviews are confined to the bounds of the receiver. Setting this value to YES causes subviews to be clipped to the bounds of the receiver. If set to NO, subviews whose frames extend beyond the visible bounds of the receiver are not clipped. The default value is NO.

Returns:

  • (Boolean)

- (UIViewContentMode) contentMode

A flag used to determine how a view lays out its content when its bounds change. The content mode specifies how the cached bitmap of the view’s layer is adjusted when the view’s bounds change. This property is often used to implement resizable controls, usually in conjunction with the contentStretch property. Instead of redrawing the contents of the view every time, you can use this property to specify that you want to scale the contents (either with or without distortion) or pin them to a particular spot on the view.Note: You can always force the contents of a view to be redrawn by calling the setNeedsDisplay or setNeedsDisplayInRect: method. For a list of values you can assign to this property, see UIViewContentMode. The default value of this property is UIViewContentModeScaleToFill.

Returns:

- (Float) contentScaleFactor

The scale factor applied to the view. The scale factor determines how content in the view is mapped from the logical coordinate space (measured in points) to the device coordinate space (measured in pixels). This value is typically either 1.0 or 2.0. Higher scale factors indicate that each point in the view is represented by more than one pixel in the underlying layer. For example, if the scale factor is 2.0 and the view frame size is 50 x 50 points, the size of the bitmap used to present that content is 100 x 100 pixels.For views that implement a custom drawRect: method and are associated with a window, the default value for this property is the scale factor associated with the screen currently displaying the view. For system views and views that are backed by a CAEAGLLayer object for, the value of this property may be 1.0 even on high resolution screens. In general, you should not need to modify the value in this property. However, if your application draws using OpenGL ES, you may want to change the scale factor to support higher-resolution drawing on screens that support it. For more information on how to adjust your OpenGL ES rendering environment, see “Supporting High-Resolution Screens” in Drawing and Printing Guide for iOS.

Returns:

- (Boolean) exclusiveTouch

A Boolean value that indicates whether the receiver handles touch events exclusively. Setting this property to YES causes the receiver to block the delivery of touch events to other views in the same window. The default value of this property is NO.

Returns:

  • (Boolean)

- (CGRect) frame

The frame rectangle, which describes the view’s location and size in its superview’s coordinate system. This rectangle defines the size and position of the view in its superview’s coordinate system. You use this rectangle during layout operations to size and position the view. Setting this property changes the point specified by the center property and the size in the bounds rectangle accordingly. The coordinates of the frame rectangle are always specified in points.Warning: If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.Changing the frame rectangle automatically redisplays the receiver without invoking the drawRect: method. If you want the drawRect: method invoked when the frame rectangle changes, set the contentMode property to UIViewContentModeRedraw. Changes to this property can be animated. However, if the transform property contains a non-identity transform, the value of the frame property is undefined and should not be modified. In that case, you can reposition the view using the center property and adjust the size using the bounds property instead.

Returns:

- (Array) gestureRecognizers

The gesture-recognizer objects currently attached to the view. Each of these objects is an instance of a subclass of the abstract base class UIGestureRecognizer. If there are no gesture recognizers attached, the value of this property is an empty array.

Returns:

- (Boolean) hidden

A Boolean value that determines whether the receiver is hidden. Setting the value of this property to YES hides the receiver and setting it to NO shows the receiver. The default value is NO.A hidden view disappears from its window and does not receive input events. It remains in its superview’s list of subviews, however, and participates in autoresizing as usual. Hiding a view with subviews has the effect of hiding those subviews and any view descendants they might have. This effect is implicit and does not alter the hidden state of the receiver’s descendants.Hiding the view that is the window’s current first responder causes the view’s next valid key view to become the new first responder. The value of this property reflects the state of the receiver only and does not account for the state of the receiver’s ancestors in the view hierarchy. Thus this property can be NO but the receiver may still be hidden if an ancestor is hidden.

Returns:

  • (Boolean)

- (CALayer) layer (readonly)

The view’s Core Animation layer used for rendering. (read-only) This property is never nil. The actual class of the object is determined by the value returned by the layerClass method. The view is the layer’s delegate.Warning: Since the view is the layer’s delegate, you should never make the view the delegate of another CALayer object. Additionally, you should never change the delegate of this layer object.

Returns:

- (Boolean) multipleTouchEnabled

A Boolean value that indicates whether the receiver handles multi-touch events. When set to YES, the receiver receives all touches associated with a multi-touch sequence. When set to NO, the receiver receives only the first touch event in a multi-touch sequence. The default value of this property is NO.Other views in the same window can still receive touch events when this property is NO. If you want this view to handle multi-touch events exclusively, set the values of both this property and the exclusiveTouch property to YES.

Returns:

  • (Boolean)

- (Boolean) opaque

A Boolean value that determines whether the receiver is opaque. This property provides a hint to the drawing system as to how it should treat the view. If set to YES, the drawing system treats the view as fully opaque, which allows the drawing system to optimize some drawing operations and improve performance. If set to NO, the drawing system composites the view normally with other content. The default value of this property is YES.An opaque view is expected to fill its bounds with entirely opaque content—that is, the content should have an alpha value of 1.0. If the view is opaque and either does not fill its bounds or contains wholly or partially transparent content, the results are unpredictable. You should always set the value of this property to NO if the view is fully or partially transparent.

Returns:

  • (Boolean)

- (String) restorationIdentifier

The identifier that determines whether the view supports state restoration. This property indicates whether state information in the view should be preserved; it is also used to identify the view during the restoration process. The value of this property is nil by default, which indicates that the view’s state does not need to be saved. Assigning a string object to the property lets the owning view controller know that the view has relevant state information to save.Assign a value to this property only if you are implementing a custom view that implements the encodeRestorableStateWithCoder: and decodeRestorableStateWithCoder: methods for saving and restoring state. You use those methods to write any view-specific state information and subsequently use that data to restore the view to its previous configuration.Important: Simply setting the value of this property is not enough to ensure that the view is preserved and restored. Its owning view controller, and all of that view controller’s parent view controllers, must also have a restoration identifier. For more information about the preservation and restoration process, see iOS App Programming Guide.

Returns:

- (Array) subviews (readonly)

The receiver’s immediate subviews. (read-only) You can use this property to retrieve the subviews associated with your custom view hierarchies. The order of the subviews in the array reflects their visible order on the screen, with the view at index 0 being the back-most view. For complex views declared in UIKit and other system frameworks, any subviews of the view are generally considered private and subject to change at any time. Therefore, you should not attempt to retrieve or modify subviews for these types of system-supplied views. If you do, your code may break during a future system update.

Returns:

- (UIView) superview (readonly)

The receiver’s superview, or nil if it has none. (read-only)

Returns:

- (Integer) tag

An integer that you can use to identify view objects in your application. The default value is 0. You can set the value of this tag and use that value to identify the view later.

Returns:

- (CGAffineTransform) transform

Specifies the transform applied to the receiver, relative to the center of its bounds. The origin of the transform is the value of the center property, or the layer’s anchorPoint property if it was changed. (Use the layer property to get the underlying Core Animation layer object.) The default value is CGAffineTransformIdentity.Changes to this property can be animated. Use the beginAnimations:context: class method to begin and the commitAnimations class method to end an animation block. The default is whatever the center value is (or anchor point if changed)Warning: If this property is not the identity transform, the value of the frame property is undefined and therefore should be ignored.

Returns:

- (Boolean) userInteractionEnabled

A Boolean value that determines whether user events are ignored and removed from the event queue. When set to NO, user events—such as touch and keyboard—intended for the view are ignored and removed from the event queue. When set to YES, events are delivered to the view normally. The default value of this property is YES. During an animation, user interactions are temporarily disabled for all views involved in the animation, regardless of the value in this property. You can disable this behavior by specifying the UIViewAnimationOptionAllowUserInteraction option when configuring the animation.Note: Some UIKit subclasses override this property and return a different default value. See the documentation for that class to determine if it returns a different value.

Returns:

  • (Boolean)

- (UIWindow) window (readonly)

The receiver’s window object, or nil if it has none. (read-only) This property is nil if the view has not yet been added to a window.

Returns:

Class Method Details

+ (Object) animateWithDuration(duration, animations:animations)

Animate changes to one or more views using the specified duration. This method performs the specified animations immediately using the UIViewAnimationOptionCurveEaseInOut and UIViewAnimationOptionTransitionNone animation options. During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.)

Parameters:

  • duration

    The total duration of the animations, measured in seconds. If you specify a negative value or 0, the changes are made without animating them.

  • animations

    A block object containing the changes to commit to the views. This is where you programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value. This parameter must not be NULL.

Returns:

+ (Object) animateWithDuration(duration, animations:animations, completion:completion)

Animate changes to one or more views using the specified duration and completion handler. This method performs the specified animations immediately using the UIViewAnimationOptionCurveEaseInOut and UIViewAnimationOptionTransitionNone animation options. For example, if you want to fade a view until it is totally transparent and then remove it from your view hierarchy, you could use code similar to the following:During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.)

Parameters:

  • duration

    The total duration of the animations, measured in seconds. If you specify a negative value or 0, the changes are made without animating them.

  • animations

    A block object containing the changes to commit to the views. This is where you programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value. This parameter must not be NULL.

  • completion

    A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL.

Returns:

+ (Object) animateWithDuration(duration, delay:delay, options:options, animations:animations, completion:completion)

Animate changes to one or more views using the specified duration, delay, options, and completion handler. This method initiates a set of animations to perform on the view. The block object in the animations parameter contains the code for animating the properties of one or more views.During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.) If you want users to be able to interact with the views, include the UIViewAnimationOptionAllowUserInteraction constant in the options parameter.

Parameters:

  • duration

    The total duration of the animations, measured in seconds. If you specify a negative value or 0, the changes are made without animating them.

  • delay

    The amount of time (measured in seconds) to wait before beginning the animations. Specify a value of 0 to begin the animations immediately.

  • options

    A mask of options indicating how you want to perform the animations. For a list of valid constants, see UIViewAnimationOptions.

  • animations

    A block object containing the changes to commit to the views. This is where you programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value. This parameter must not be NULL.

  • completion

    A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL.

Returns:

+ (Boolean) areAnimationsEnabled

Returns a Boolean value indicating whether animations are enabled.

Returns:

  • (Boolean)

    YES if animations are enabled; otherwise, NO.

+ (Object) beginAnimations(animationID, context:context)

Marks the beginning of a begin/commit animation block. This method signals to the system that you want to specify one or more animations to perform. After calling this method, configure the animation options (using the setAnimation… class methods) and then change the desired animatable properties of your views. When you are done changing your view properties, call the commitAnimations method to close the set and schedule the animations.You can nest sets of animations (by calling this method again before committing a previous set of animations) as needed. Nesting animations groups them together and allows you to set different animation options for the nested group.If you install a start or stop selector using the setAnimationWillStartSelector: or setAnimationDidStopSelector: method, the values you specify for the animationID and context parameters are passed to your selectors at runtime. You can use these parameters to pass additional information to those selectors.Use of this method is discouraged in iOS 4.0 and later. You should use the block-based animation methods to specify your animations instead.

Parameters:

  • animationID (String)

    An application-supplied identifier for the animations.

  • context (Object)

    Custom data that you want to associate with this set of animations. information that is passed to the animation delegate messages—the selectors set using the setAnimationWillStartSelector: and setAnimationDidStopSelector: methods.

Returns:

+ (Object) commitAnimations

Marks the end of a begin/commit animation block and schedules the animations for execution. If the current animation set is the outermost set, this method starts the animations when the application returns to the run loop. If the current animation set is nested inside another set, this method waits until the outermost set of animations is committed, at which point it commits all of the animations together. Animations run in a separate thread to avoid blocking the application. In this way, multiple animations can be piled on top of one another. See setAnimationBeginsFromCurrentState: for how to start animations while others are in progress.Use of this method is discouraged in iOS 4.0 and later. You should use the block-based animation methods to specify your animations instead.

Returns:

+ (Class) layerClass

Returns the class used to create the layer for instances of this class. This method returns the CALayer class object by default. Subclasses can override this method and return a different layer class as needed. For example, if you use OpenGL ES to do your drawing, you would override this method and return the class object for the CAEAGLLayer class.This method is called only once early in the creation of the view in order to create the corresponding layer object.

Returns:

  • (Class)

    The class used to create the view’s Core Animation layer.

+ (Boolean) requiresConstraintBasedLayout

Returns whether the receiver depends on the constraint-based layout system. Custom views should override this to return YES if they can not layout correctly using autoresizing.

Returns:

  • (Boolean)

    YES if the view must be in a window using constraint-based layout to function properly, NO otherwise.

+ (Object) setAnimationBeginsFromCurrentState(fromCurrentState)

Sets whether the animation should begin playing from the current state. If set to YES when an animation is in flight, the current view position of the in-flight animation is used as the starting state for the new animation. If set to NO, the in-flight animation ends before the new animation begins using the last view position as the starting state. This method does nothing if an animation is not in flight or invoked outside of an animation block. Use the beginAnimations:context: class method to start and the commitAnimations class method to end an animation block. The default value is NO.Use of this method is discouraged in iOS 4.0 and later. Instead, you should use theanimateWithDuration:delay:options:animations:completion: method to specify your animations and the animation options.

Parameters:

  • fromCurrentState (Boolean)

    Specify YES if animations should begin from their currently visible state; otherwise, NO.

Returns:

+ (Object) setAnimationCurve(curve)

Sets the curve to use when animating property changes within an animation block. If you specify your animations using begin/commit set of methods, you use this method to specify the type of curve you want to use for the animation. This method does nothing if called from outside of an animation block. It must be called between calls to the beginAnimations:context: and commitAnimations methods. And you must call this method prior to changing the animatable properties of your views. The default value is UIViewAnimationCurveEaseInOut.Use of this method is discouraged in iOS 4.0 and later. Instead, you should use theanimateWithDuration:delay:options:animations:completion: method to specify your animations and the animation curve options.

Returns:

+ (Object) setAnimationDelay(delay)

Sets the amount of time (in seconds) to wait before animating property changes within an animation block. If you specify your animations using begin/commit set of methods, you use this method to specify the amount of time to wait before starting the animations. This method does nothing if called from outside of an animation block. It must be called between calls to the beginAnimations:context: and commitAnimations methods. And you must call this method prior to changing the animatable properties of your views. The default value is 0.0 seconds.Use of this method is discouraged in iOS 4.0 and later. Instead, you should use theanimateWithDuration:delay:options:animations:completion: method to specify your animations and the starting delay.

Returns:

+ (Object) setAnimationDelegate(delegate)

Sets the delegate for any animation messages. You can specify an animation delegate in cases where you want to receive messages when the animation starts or stops. After calling this method, you should call the setAnimationWillStartSelector: and setAnimationDidStopSelector: methods as needed to register appropriate selectors. By default, the animation delegate is set to nil. You primarily use this method to set the delegate for animation blocks created using the begin/commit animation methods. Calling this method from outside an animation block does nothing.Use of this method is discouraged in iOS 4.0 and later. If you are using the block-based animation methods, you can include your delegate’s start and end code directly inside your block.

Parameters:

  • delegate (Object)

    An object that defines the methods registered using the setAnimationWillStartSelector: and setAnimationDidStopSelector: methods. This object is retained by the view for the duration of the animation.

Returns:

+ (Object) setAnimationDidStopSelector(selector)

Sets the message to send to the animation delegate when animation stops. If you specify an animation delegate for a begin/commit set of animations, you use this method to specify the selector to call after the animations end. This method does nothing if called from outside of an animation block. It must be called between calls to the beginAnimations:context: and commitAnimations methods. This selector is set to NULL by default.Note: Your stop selector is still called even if animations are disabled.Use of this method is discouraged in iOS 4.0 and later. If you are using the block-based animation methods, you can include your delegate’s end code directly inside your block.

Parameters:

  • selector (Symbol)

    The message sent to the animation delegate after animations end. The default value is NULL. The selector should be of the form: - (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context. Your method must take the following arguments:animationIDAn NSString containing an optional application-supplied identifier. This is the identifier that is passed to the beginAnimations:context: method. This argument can be nil.finishedAn NSNumber object containing a Boolean value. The value is YES if the animation ran to completion before it stopped or NO if it did not.contextAn optional application-supplied context. This is the context data passed to the beginAnimations:context: method. This argument can be nil.

Returns:

+ (Object) setAnimationDuration(duration)

Sets the duration (measured in seconds) of the animations in an animation block. If you specify your animations using begin/commit set of methods, you use this method to specify the duration of the animations. This method does nothing if called from outside of an animation block. It must be called between calls to the beginAnimations:context: and commitAnimations methods. And you must call this method prior to changing the animatable properties of your views. The default value is 0.2 seconds.Use of this method is discouraged in iOS 4.0 and later. Instead, you should use any of the block-based animation methods to specify your animations and their duration.

Parameters:

  • duration (NSTimeInterval)

    The period over which the animation occurs, measured in seconds.

Returns:

+ (Object) setAnimationRepeatAutoreverses(repeatAutoreverses)

Sets whether the animations within an animation block automatically reverse themselves. If you enable autoreversing, a single animation cycle changes the properties being animated to their new values and then back to their original values. At the end of the animations, the affected views are then updated immediately to reflect the new values. This method does nothing if called from outside of an animation block. By default, autoreversing is disabled. If you combine autoreversing with a repeat count (settable using the setAnimationRepeatCount: method), you can create animations that shift back and forth between the old and new values the specified number of times. However, remember that the repeat count indicates the number of complete cycles. If you specify an integral value such as 2.0, the animation ends on the old value, which is followed by the view immediately updating itself to show the new value, which might be jarring. If you want the animation to end on the new value (instead of the old value), add 0.5 to the repeat count value. This adds an extra half cycle to the animation. Use of this method is discouraged in iOS 4.0 and later. Instead, you should use theanimateWithDuration:delay:options:animations:completion: method to specify your animations and the animation options.

Parameters:

  • repeatAutoreverses (Boolean)

    Specify YES to enable autoreversing or NO to disable it.

Returns:

+ (Object) setAnimationRepeatCount(repeatCount)

Sets the number of times animations within an animation block repeat. Use this method to specify the number of times to repeat the specified animations. This method does nothing if called from outside of an animation block. You can use this method in conjunction with either the block-based methods or the begin/commit methods for defining an animation block. If you do not explicitly set a repeat count, the animation is not repeated. If you pass the UIViewAnimationOptionRepeat option to the animateWithDuration:delay:options:animations:completion: method without setting an explicit repeat count, the animation repeats indefinitely. If you want the animation to repeat a finite number of times, call this method from inside your block.

Parameters:

  • repeatCount (Float)

    The number of times animations repeat. This value can be a fraction. If you specify the value 0, the animation is performed once without repeating.

Returns:

+ (Object) setAnimationsEnabled(enabled)

Sets whether animations are enabled. Animations are enabled by default. If you disable animations, code inside subsequent animation blocks is still executed but no animations actually occur. Thus, any changes you make inside an animation block are reflected immediately instead of being animated. This is true whether you use the block-based animation methods or the begin/commit animation methods.This method affects only those animations that are submitted after it is called. If you call this method while existing animations are running, those animations continue running until they reach their natural end point.

Parameters:

  • enabled (Boolean)

    Specify YES to enable animations or NO to disable them.

Returns:

+ (Object) setAnimationStartDate(startTime)

Sets the start time for the current animation block. Call this method between the beginAnimations:context: and commitAnimations methods to specify the start time for that set of animations. And call this method prior to changing the animatable properties of your views. (Do not call this method in conjunction with a block-based animation.) If you do not call this method, the start time is set to the value returned by the CFAbsoluteTimeGetCurrent function, which begins the animations as soon as possible. Use of this method is discouraged in iOS 4.0 and later. You should use the block-based animation methods to specify your animations instead.

Parameters:

  • startTime (NSDate)

    The time to begin the animations.

Returns:

+ (Object) setAnimationTransition(transition, forView:view, cache:cache)

Sets a transition to apply to a view during an animation block. If you want to change the appearance of a view during a transition—for example, flip from one view to another—then use a container view, an instance of UIView, as follows:Begin an animation block.Set the transition on the container view.Remove the subview from the container view.Add the new subview to the container view.Commit the animation block.Use of this method is discouraged in iOS 4.0 and later. You should use the transitionWithView:duration:options:animations:completion: method to perform transitions instead.

Parameters:

  • transition (UIViewAnimationTransition)

    A transition to apply to view. Possible values are described in UIViewAnimationTransition.

  • view (UIView)

    The view to apply the transition to.

  • cache (Boolean)

    If YES, the before and after images of view are rendered once and used to create the frames in the animation. Caching can improve performance but if you set this parameter to YES, you must not update the view or its subviews during the transition. Updating the view and its subviews may interfere with the caching behaviors and cause the view contents to be rendered incorrectly (or in the wrong location) during the animation. You must wait until the transition ends to update the view.If NO, the view and its contents must be updated for each frame of the transition animation, which may noticeably affect the frame rate.

Returns:

+ (Object) setAnimationWillStartSelector(selector)

Sets the message to send to the animation delegate when the animation starts. If you specify an animation delegate for a begin/commit set of animations, you use this method to specify the selector to call before the animations begin. This method does nothing if called from outside of an animation block. It must be called between calls to the beginAnimations:context: and commitAnimations methods. This selector is set to NULL by default.Note: Your start selector is not called if animations are disabled.Use of this method is discouraged in iOS 4.0 and later. If you are using the block-based animation methods, you can include your delegate’s start code directly inside your block.

Parameters:

  • selector (Symbol)

    The message to send to the animation delegate before animations start. The default value is NULL. This selector should be of the form: - (void)animationDidStart:(NSString *)animationID context:(void *)context. Your method must take the following arguments:animationIDAn NSString containing an optional application-supplied identifier. This is the identifier string that is passed to the beginAnimations:context: method. This argument can be nil.contextAn optional application-supplied context. This is the context data passed to the beginAnimations:context: method. This argument can be nil.

Returns:

+ (Object) transitionFromView(fromView, toView:toView, duration:duration, options:options, completion:completion)

Creates a transition animation between the specified views using the given parameters. This method provides a simple way to transition from the view in the fromView parameter to the view in the toView parameter. By default, the view in fromView is replaced in the view hierarchy by the view in toView. If both views are already part of your view hierarchy, you can include the UIViewAnimationOptionShowHideTransitionViews option in the options parameter to simply hide or show them. This method modifies the views in their view hierarchy only. It does not modify your application’s view controllers in any way. For example, if you use this method to change the root view displayed by a view controller, it is your responsibility to update the view controller appropriately to handle the change. The view transition starts immediately unless another animation is already in-flight, in which case it starts immediately after the current animation finishes. During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.) If you want users to be able to interact with the views, include the UIViewAnimationOptionAllowUserInteraction constant in the options parameter.

Parameters:

  • fromView

    The starting view for the transition. By default, this view is removed from its superview as part of the transition.

  • toView

    The ending view for the transition. By default, this view is added to the superview of fromView as part of the transition.

  • duration

    The duration of the transition animation, measured in seconds. If you specify a negative value or 0, the transition is made without animations.

  • options

    A mask of options indicating how you want to perform the animations. For a list of valid constants, see UIViewAnimationOptions.

  • completion

    A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL.

Returns:

+ (Object) transitionWithView(view, duration:duration, options:options, animations:animations, completion:completion)

Creates a transition animation for the specified container view. This method applies a transition to the specified view so that you can make state changes to it. The block you specify in the animations parameter contains whatever state changes you want to make. You can use this block to add, remove, show, or hide subviews of the specified view. If you want to incorporate other animatable changes, you must include the UIViewAnimationOptionAllowAnimatedContent key in the options parameter. The following code creates a flip transition for the specified container view. At the appropriate point in the transition, one subview is removed and another is added to the container view. This makes it look as if a new view was flipped into place with the new subview, but really it is just the same view animated back into place with a new configuration.During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.) If you want users to be able to interact with the views, include the UIViewAnimationOptionAllowUserInteraction constant in the options parameter.

Parameters:

  • view

    The container view that performs the transition.

  • duration

    The duration of the transition animation, measured in seconds. If you specify a negative value or 0, the transition is made without animations.

  • options

    A mask of options indicating how you want to perform the animations. For a list of valid constants, see UIViewAnimationOptions.

  • animations

    A block object that contains the changes you want to make to the specified view. This block takes no parameters and has no return value. This parameter must not be NULL.

  • completion

    A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL.

Returns:

Instance Method Details

- (Object) addConstraint(constraint)

Adds a constraint on the layout of the receiving view or its subviews. The constraint must involve only views that are within scope of the receiving view. Specifically, any views involved must be either the receiving view itself, or a subview of the receiving view. Constraints that are added to a view are said to be held by that view. The coordinate system used when evaluating the constraint is the coordinate system of the view that holds the constraint.

Parameters:

  • constraint (NSLayoutConstraint)

    The constraint to be added to the view. The constraint may only reference the view itself or its subviews.

Returns:

- (Object) addConstraints(constraints)

Adds multiple constraints on the layout of the receiving view or its subviews. All constraints must involve only views that are within scope of the receiving view. Specifically, any views involved must be either the receiving view itself, or a subview of the receiving view. Constraints that are added to a view are said to be held by that view. The coordinate system used when evaluating each constraint is the coordinate system of the view that holds the constraint.

Parameters:

  • constraints (Array)

    An array of constraints to be added to the view. All constraints may only reference the view itself or its subviews.

Returns:

- (Object) addGestureRecognizer(gestureRecognizer)

Attaches a gesture recognizer to the view. Attaching a gesture recognizer to a view defines the scope of the represented gesture, causing it to receive touches hit-tested to that view and all of its subviews. The view retains the gesture recognizer.

Parameters:

Returns:

- (Object) addSubview(view)

Adds a view to the end of the receiver’s list of subviews. This method retains view and sets its next responder to the receiver, which is its new superview. Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.

Parameters:

  • view (UIView)

    The view to be added. This view is retained by the receiver. After being added, this view appears on top of any other subviews.

Returns:

- (CGRect) alignmentRectForFrame(frame)

Returns the view’s alignment rectangle for a given frame. The constraint-based layout system uses alignment rectangles to align views, rather than their frame. This allows custom views to be aligned based on the location of their content while still having a frame that encompasses any ornamentation they need to draw around their content, such as shadows or reflections.The default implementation returns the view’s frame modified by the view’s alignmentRectInsets. Most custom views can override alignmentRectInsets to specify the location of their content within their frame. Custom views that require arbitrary transformations can override alignmentRectForFrame: and frameForAlignmentRect: to describe the location of their content. These two methods must always be inverses of each other.

Parameters:

  • frame (CGRect)

    The frame whose corresponding alignment rectangle is desired.

Returns:

  • (CGRect)

    The alignment rectangle for the specified frame.

- (UIEdgeInsets) alignmentRectInsets

Returns the insets from the view’s frame that define its alignment rectangle. The default implementation of this method returns an NSEdgeInsets structure with zero values. Custom views that draw ornamentation around their content should override this method to return insets that align with the edges of the content, excluding the ornamentation. This allows the constraint-based layout system to align views based on their content, rather than just their frame.Custom views whose content location can’t be expressed by a simple set of insets should override alignmentRectForFrame: and frameForAlignmentRect: to describe their custom transform between alignment rectangle and frame.

Returns:

  • (UIEdgeInsets)

    The insets from the view’s frame that define its alignment rectangle.

- (Object) bringSubviewToFront(view)

Moves the specified subview so that it appears on top of its siblings. This method moves the specified view to the end of the array of views in the subviews property.

Parameters:

  • view (UIView)

    The subview to move to the front.

Returns:

- (Array) constraints

Returns the constraints held by the view.

Returns:

  • (Array)

    The constraints held by the view.

- (Array) constraintsAffectingLayoutForAxis(axis)

Returns the constraints impacting the layout of the view for a given axis. The returned set of constraints may not all include the view explicitly. Constraints that impact the location of the view implicitly may also be included. While this provides a good starting point for debugging, there is no guarantee that the returned set of constraints will include all of the constraints that have an impact on the view’s layout in the given orientation.This method should only be used for debugging constraint-based layout. No application should ship with calls to this method as part of its operation.

Parameters:

  • axis (UILayoutConstraintAxis)

    The axis for which the constraints should be found.

Returns:

  • (Array)

    The constraints impacting the layout of the view for the specified axis.

- (UILayoutPriority) contentCompressionResistancePriorityForAxis(axis)

Returns the priority with which a view resists being made smaller than its intrinsic size. The constraint-based layout system uses these priorities when determining the best layout for views that are encountering constraints that would require them to be smaller than their intrinsic size.Subclasses should not override this method. Instead, custom views should set default values for their content on creation, typically to NSLayoutPriorityDefaultLow or NSLayoutPriorityDefaultHigh.

Parameters:

  • axis (UILayoutConstraintAxis)

    The axis of the view that might be reduced.

Returns:

  • (UILayoutPriority)

    The priority with which the view should resist being compressed from its intrinsic size on the specified axis.

- (UILayoutPriority) contentHuggingPriorityForAxis(axis)

Returns the priority with which a view resists being made larger than its intrinsic size. The constraint-based layout system uses these priorities when determining the best layout for views that are encountering constraints that would require them to be larger than their intrinsic size.

Parameters:

  • axis (UILayoutConstraintAxis)

    The axis of the view that might be enlarged.

Returns:

  • (UILayoutPriority)

    The priority with which the view should resist being enlarged from its intrinsic size on the specified axis.

- (CGPoint) convertPoint(point, fromView:view)

Converts a point from the coordinate system of a given view to that of the receiver.

Parameters:

  • point (CGPoint)

    A point specified in the local coordinate system (bounds) of view.

  • view (UIView)

    The view with point in its coordinate system. If view is nil, this method instead converts from window base coordinates. Otherwise, both view and the receiver must belong to the same UIWindow object.

Returns:

  • (CGPoint)

    The point converted to the local coordinate system (bounds) of the receiver.

- (CGPoint) convertPoint(point, toView:view)

Converts a point from the receiver’s coordinate system to that of the specified view.

Parameters:

  • point (CGPoint)

    A point specified in the local coordinate system (bounds) of the receiver.

  • view (UIView)

    The view into whose coordinate system point is to be converted. If view is nil, this method instead converts to window base coordinates. Otherwise, both view and the receiver must belong to the same UIWindow object.

Returns:

  • (CGPoint)

    The point converted to the coordinate system of view.

- (CGRect) convertRect(rect, fromView:view)

Converts a rectangle from the coordinate system of another view to that of the receiver.

Parameters:

  • rect (CGRect)

    A rectangle specified in the local coordinate system (bounds) of view.

  • view (UIView)

    The view with rect in its coordinate system. If view is nil, this method instead converts from window base coordinates. Otherwise, both view and the receiver must belong to the same UIWindow object.

Returns:

  • (CGRect)

    The converted rectangle.

- (CGRect) convertRect(rect, toView:view)

Converts a rectangle from the receiver’s coordinate system to that of another view.

Parameters:

  • rect (CGRect)

    A rectangle specified in the local coordinate system (bounds) of the receiver.

  • view (UIView)

    The view that is the target of the conversion operation. If view is nil, this method instead converts to window base coordinates. Otherwise, both view and the receiver must belong to the same UIWindow object.

Returns:

  • (CGRect)

    The converted rectangle.

- (Object) decodeRestorableStateWithCoder(coder)

Decodes and restores state-related information for the view. If your app supports state restoration, you should override this method for any views for which you also overrode the encodeRestorableStateWithCoder: method. Your implementation of this method should use any saved state information to restore the view to its previous configuration. If your encodeRestorableStateWithCoder: method called super, this method should similarly call super at some point in its implementation.

Parameters:

  • coder (NSCoder)

    The coder object to use to decode the state of the view.

Returns:

- (Object) didAddSubview(subview)

Tells the view that a subview was added. The default implementation of this method does nothing. Subclasses can override it to perform additional actions when subviews are added. This method is called in response to adding a subview using any of the relevant view methods.

Parameters:

  • subview (UIView)

    The view that was added as a subview.

Returns:

- (Object) didMoveToSuperview

Tells the view that its superview changed. The default implementation of this method does nothing. Subclasses can override it to perform additional actions whenever the superview changes.

Returns:

- (Object) didMoveToWindow

Tells the view that its window object changed. The default implementation of this method does nothing. Subclasses can override it to perform additional actions whenever the window changes.The window property may be nil by the time that this method is called, indicating that the receiver does not currently reside in any window. This occurs when the receiver has just been removed from its superview or when the receiver has just been added to a superview that is not attached to a window. Overrides of this method may choose to ignore such cases if they are not of interest.

Returns:

- (Object) drawRect(rect)

Draws the receiver’s image within the passed-in rectangle. The default implementation of this method does nothing. Subclasses that use native drawing technologies (such as Core Graphics and UIKit) to draw their view’s content should override this method and implement their drawing code there. You do not need to override this method if your view sets its content in other ways. For example, you do not need to override this method if your view just displays a background color or if your view sets its content directly using the underlying layer object. Similarly, you should not override this method if your view uses OpenGL ES to do its drawing. By the time this method is called, UIKit has configured the drawing environment appropriately for your view and you can simply call whatever drawing methods and functions you need to render your content. Specifically, UIKit creates and configures a graphics context for drawing and adjusts the transform of that context so that its origin matches the origin of your view’s bounds rectangle. You can get a reference to the graphics context using the UIGraphicsGetCurrentContext function, but do not retain the graphics context because it can change between calls to the drawRect: method.You should limit any drawing to the rectangle specified in the rect parameter. In addition, if the opaque property of your view is set to YES, your drawRect: method must totally fill the specified rectangle with opaque content. If you subclass UIView directly, your implementation of this method does not need to call super. However, if you are subclassing a different view class, you should call super at some point in your implementation. This method is called when a view is first displayed or when an event occurs that invalidates a visible part of the view. You should never call this method directly yourself. To invalidate part of your view, and thus cause that portion to be redrawn, call the setNeedsDisplay or setNeedsDisplayInRect: method instead.

Parameters:

  • rect (CGRect)

    The portion of the view’s bounds that needs to be updated. The first time your view is drawn, this rectangle is typically the entire visible bounds of your view. However, during subsequent drawing operations, the rectangle may specify only part of your view.

Returns:

- (Object) drawRect(area, forViewPrintFormatter:formatter)

Implemented to draw the view’s content for printing. You implement this method if you want a view’s printed content to appear differently than its displayed content. If you add a view print formatter to a print job but do not implement this method, the view’s drawRect: method is called to provide the content for printing. For more information about how to implement a custom drawing routine for printed content, see Drawing and Printing Guide for iOS.

Parameters:

Returns:

- (Object) encodeRestorableStateWithCoder(coder)

Encodes state-related information for the view. If your app supports state preservation, you can override this method for any views that have state information that should be saved between launches of your app. You should save only the data required to return the view to its current configuration. Do not save the view object itself and do not save any data that could be determined by other means at launch time.Few views should need to save state information. Most views should just be configured using the data from their view controller. However, this method is available for those views that have user-configurable state that would be otherwise lost between app launches.Your implementation of this method can encode other restorable view and view controller objects that it needs to reference. Encoding a restorable view or view controller writes that object’s restoration identifier to the coder. (That identifier is used during the decode process to locate the new version of the object.) If the view or view controller defines its own own version of this method, that method is also called at some point so that the object can encode its own state. Apart from views and view controllers, other objects follow the normal serialization process and must adopt the NSCoding protocol before they can be encoded. Encoding such objects embeds the object’s contents in the archive directly. During the decode process, a new object is created and initialized with the data from the archive.It is recommended that you call super at some point during your implementation to give parent classes an opportunity to save their state information.

Parameters:

  • coder (NSCoder)

    The coder object to use to encode the state of the view.

Returns:

- (Boolean) endEditing(force)

Causes the view (or one of its embedded text fields) to resign the first responder status. This method looks at the current view and its subview hierarchy for the text field that is currently the first responder. If it finds one, it asks that text field to resign as first responder. If the force parameter is set to YES, the text field is never even asked; it is forced to resign.

Parameters:

  • force (Boolean)

    Specify YES to force the first responder to resign, regardless of whether it wants to do so.

Returns:

  • (Boolean)

    YES if the view resigned the first responder status or NO if it did not.

- (Object) exchangeSubviewAtIndex(index1, withSubviewAtIndex:index2)

Exchanges the subviews at the specified indices. Each index represents the position of the corresponding view in the array in the subviews property. Subview indices start at 0 and cannot be greater than the number of subviews. This method does not change the superview of either view but simply swaps their positions in the subviews array.

Parameters:

  • index1 (Integer)

    The index of the first subview in the receiver.

  • index2 (Integer)

    The index of the second subview in the receiver.

Returns:

- (Object) exerciseAmbiguityInLayout

Randomly changes the frame of a view with an ambiguous layout between the different valid values. This method randomly changes the frame of a view with an ambiguous layout between its different valid values, causing the view to move in the interface. This makes it easy to visually identify what the valid frames are and may enable the developer to discern what constraints need to be added to the layout to fully specify a location for the view.This method should only be used for debugging constraint-based layout. No application should ship with calls to this method as part of its operation.

Returns:

- (CGRect) frameForAlignmentRect(alignmentRect)

Returns the view’s frame for a given alignment rectangle. The constraint-based layout system uses alignment rectangles to align views, rather than their frame. This allows custom views to be aligned based on the location of their content while still having a frame that encompasses any ornamentation they need to draw around their content, such as shadows or reflections.The default implementation returns alignmentRect modified by the view’s alignmentRectInsets. Most custom views can override alignmentRectInsets to specify the location of their content within their frame. Custom views that require arbitrary transformations can override alignmentRectForFrame: and frameForAlignmentRect: to describe the location of their content. These two methods must always be inverses of each other.

Parameters:

  • alignmentRect (CGRect)

    The alignment rectangle whose corresponding frame is desired.

Returns:

  • (CGRect)

    The frame for the specified alignment rectangle

- (Boolean) gestureRecognizerShouldBegin(gestureRecognizer)

Asks the view if the gesture recognizer should be allowed to continue tracking touch events. Subclasses may override this method and use it to prevent the recognition of particular gestures. For example, the UISlider class uses this method to prevent swipes parallel to the slider’s travel direction and that start in the thumb. At the time this method is called, the gesture recognizer is in the UIGestureRecognizerStatePossible state and thinks it has the events needed to move to the UIGestureRecognizerStateBegan state. The default implementation of this method returns YES.

Parameters:

  • gestureRecognizer (UIGestureRecognizer)

    The gesture recognizer that is attempting to transition out of the UIGestureRecognizerStatePossible state.

Returns:

  • (Boolean)

    YES if the gesture recognizer should continue tracking touch events and use them to trigger a gesture or NO if it should transition to the UIGestureRecognizerStateFailed state.

- (Boolean) hasAmbiguousLayout

Returns whether the constraints impacting the layout of the view incompletely specify the location of the view. This method checks to see if there is any other frame the view could have that would also satisfy the constraints on the view. This is an expensive operation and is not run as part of the normal layout process, but can be useful when debugging whether a given interface has been specified with a sufficient number of constraints to ensure consistent layout.This method should only be used for debugging constraint-based layout. No application should ship with calls to this method as part of its operation.

Returns:

  • (Boolean)

    YES if the view’s location is incompletely specified, NO otherwise.

- (UIView) hitTest(point, withEvent:event)

Returns the farthest descendant of the receiver in the view hierarchy (including itself) that contains a specified point. This method traverses the view hierarchy by sending the pointInside:withEvent: message to each subview to determine which subview should receive a touch event. If pointInside:withEvent: returns YES, then the subview’s hierarchy is traversed; otherwise, its branch of the view hierarchy is ignored. You rarely need to call this method yourself, but you might override it to hide touch events from subviews. This method ignores view objects that are hidden, that have disabled user interactions, or have an alpha level less than 0.01. This method does not take the view’s content into account when determining a hit. Thus, a view can still be returned even if the specified point is in a transparent portion of that view’s content.Points that lie outside the receiver’s bounds are never reported as hits, even if they actually lie within one of the receiver’s subviews. This can occur if the current view’s clipsToBounds property is set to NO and the affected subview extends beyond the view’s bounds.

Parameters:

  • point (CGPoint)

    A point specified in the receiver’s local coordinate system (bounds).

  • event (UIEvent)

    The event that warranted a call to this method. If you are calling this method from outside your event-handling code, you may specify nil.

Returns:

  • (UIView)

    The view object that is the farthest descendent the current view and contains point. Returns nil if the point lies completely outside the receiver’s view hierarchy.

- (Object) initWithFrame(aRect)

Initializes and returns a newly allocated view object with the specified frame rectangle. The new view object must be inserted into the view hierarchy of a window before it can be used. If you create a view object programmatically, this method is the designated initializer for the UIView class. Subclasses can override this method to perform any custom initialization but must call super at the beginning of their implementation.If you use Interface Builder to design your interface, this method is not called when your view objects are subsequently loaded from the nib file. Objects in a nib file are reconstituted and then initialized using their initWithCoder: method, which modifies the attributes of the view to match the attributes stored in the nib file. For detailed information about how views are loaded from a nib file, see Resource Programming Guide.

Parameters:

  • aRect (CGRect)

    The frame rectangle for the view, measured in points. The origin of the frame is relative to the superview in which you plan to add it. This method uses the frame rectangle to set the center and bounds properties accordingly.

Returns:

  • (Object)

    An initialized view object or nil if the object couldn't be created.

- (Object) insertSubview(view, aboveSubview:siblingSubview)

Inserts a view above another view in the view hierarchy. This method retains view and sets its next responder to the receiver, which is its new superview. Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.

Parameters:

  • view (UIView)

    The view to insert. It’s removed from its superview if it’s not a sibling of siblingSubview.

  • siblingSubview (UIView)

    The sibling view that will be behind the inserted view.

Returns:

- (Object) insertSubview(view, atIndex:index)

Inserts a subview at the specified index. This method retains view and sets its next responder to the receiver, which is its new superview. Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.

Parameters:

  • view (UIView)

    The view to insert. This value cannot be nil.

  • index (Integer)

    The index in the array of the subviews property at which to insert the view. Subview indices start at 0 and cannot be greater than the number of subviews.

Returns:

- (Object) insertSubview(view, belowSubview:siblingSubview)

Inserts a view below another view in the view hierarchy. This method retains view and sets its next responder to the receiver, which is its new superview. Views can have only one superview. If view already has a superview and that view is not the receiver, this method removes the previous superview before making the receiver its new superview.

Parameters:

  • view (UIView)

    The view to insert below another view. It’s removed from its superview if it’s not a sibling of siblingSubview.

  • siblingSubview (UIView)

    The sibling view that will be above the inserted view.

Returns:

- (CGSize) intrinsicContentSize

Returns the natural size for the receiving view, considering only properties of the view itself. Custom views typically have content that they display of which the layout system is unaware. Overriding this method allows a custom view to communicate to the layout system what size it would like to be based on its content. This intrinsic size must be independent of the content frame, because there’s no way to dynamically communicate a changed width to the layout system based on a changed height, for example.If a custom view has no intrinsic size for a given dimension, it can return UIViewNoIntrinsicMetric for that dimension.

Returns:

  • (CGSize)

    A size indicating the natural size for the receiving view based on its intrinsic properties.

- (Object) invalidateIntrinsicContentSize

Invalidates the view’s intrinsic content size. Call this when something changes in your custom view that invalidates its intrinsic content size. This allows the constraint-based layout system to take the new intrinsic content size into account in its next layout pass.

Returns:

- (Boolean) isDescendantOfView(view)

Returns a Boolean value indicating whether the receiver is a subview of a given view or identical to that view.

Parameters:

  • view (UIView)

    The view to test against the receiver’s view hierarchy.

Returns:

  • (Boolean)

    YES if the receiver is an immediate or distant subview of view or if view is the receiver itself; otherwise NO.

- (Object) layoutIfNeeded

Lays out the subviews immediately. Use this method to force the layout of subviews before drawing. Starting with the receiver, this method traverses upward through the view hierarchy as long as superviews require layout. Then it lays out the entire tree beneath that ancestor. Therefore, calling this method can potentially force the layout of your entire view hierarchy. The UIView implementation of this calls the equivalent CALayer method and so has the same behavior as CALayer.

Returns:

- (Object) layoutSubviews

Lays out subviews. The default implementation of this method does nothing on iOS 5.1 and earlier. Otherwise, the default implementation uses any constraints you have set to determine the size and position of any subviews.Subclasses can override this method as needed to perform more precise layout of their subviews. You should override this method only if the autoresizing and constraint-based behaviors of the subviews do not offer the behavior you want. You can use your implementation to set the frame rectangles of your subviews directly.You should not call this method directly. If you want to force a layout update, call the setNeedsLayout method instead to do so prior to the next drawing update. If you want to update the layout of your views immediately, call the layoutIfNeeded method.

Returns:

- (Boolean) needsUpdateConstraints

Returns whether the view’s constraints need updating. The constraint-based layout system uses the return value of this method to determine whether it needs to call updateConstraints on your view as part of its normal layout pass.

Returns:

  • (Boolean)

    YES if the view’s constraints need updating, NO otherwise.

- (Boolean) pointInside(point, withEvent:event)

Returns a Boolean value indicating whether the receiver contains the specified point.

Parameters:

  • point (CGPoint)

    A point that is in the receiver’s local coordinate system (bounds).

  • event (UIEvent)

    The event that warranted a call to this method. If you are calling this method from outside your event-handling code, you may specify nil.

Returns:

  • (Boolean)

    YES if point is inside the receiver’s bounds; otherwise, NO.

- (Object) removeConstraint(constraint)

Removes the specified constraint from the view.

Parameters:

  • constraint (NSLayoutConstraint)

    The constraint to remove. Removing a constraint not held by the view has no effect.

Returns:

- (Object) removeConstraints(constraints)

Removes the specified constraints from the view.

Parameters:

  • constraints (Array)

    The constraints to remove.

Returns:

- (Object) removeFromSuperview

Unlinks the receiver from its superview and its window, and removes it from the responder chain. If the receiver’s superview is not nil, the superview releases the receiver. If you plan to reuse a view, be sure to retain it before calling this method and release it again later as appropriate.Never call this method from inside your view’s drawRect: method.

Returns:

- (Object) removeGestureRecognizer(gestureRecognizer)

Detaches a gesture recognizer from the receiving view. This method releases gestureRecognizer in addition to detaching it from the view.

Parameters:

Returns:

- (Object) sendSubviewToBack(view)

Moves the specified subview so that it appears behind its siblings. This method moves the specified view to the beginning of the array of views in the subviews property.

Parameters:

  • view (UIView)

    The subview to move to the back.

Returns:

- (Object) setContentCompressionResistancePriority(priority, forAxis:axis)

Sets the priority with which a view resists being made smaller than its intrinsic size. Custom views should set default values for both orientations on creation, based on their content, typically to NSLayoutPriorityDefaultLow or NSLayoutPriorityDefaultHigh. When creating user interfaces, the layout designer can modify these priorities for specific views when the overall layout design requires different tradeoffs than the natural priorities of the views being used in the interface.Subclasses should not override this method.

Parameters:

  • priority (UILayoutPriority)

    The new priority.

  • axis (UILayoutConstraintAxis)

    The axis for which the compression resistance priority should be set.

Returns:

- (Object) setContentHuggingPriority(priority, forAxis:axis)

Sets the priority with which a view resists being made larger than its intrinsic size. Custom views should set default values for both orientations on creation, based on their content, typically to NSLayoutPriorityDefaultLow or NSLayoutPriorityDefaultHigh. When creating user interfaces, the layout designer can modify these priorities for specific views when the overall layout design requires different tradeoffs than the natural priorities of the views being used in the interface.Subclasses should not override this method.

Parameters:

  • priority (UILayoutPriority)

    The new priority.

  • axis (UILayoutConstraintAxis)

    The axis for which the content hugging priority should be set.

Returns:

- (Object) setNeedsDisplay

Marks the receiver’s entire bounds rectangle as needing to be redrawn. You can use this method or the setNeedsDisplayInRect: to notify the system that your view’s contents need to be redrawn. This method makes a note of the request and returns immediately. The view is not actually redrawn until the next drawing cycle, at which point all invalidated views are updated.Note: If your view is backed by a CAEAGLLayer object, this method has no effect. It is intended for use only with views that use native drawing technologies (such as UIKit and Core Graphics) to render their content.You should use this method to request that a view be redrawn only when the content or appearance of the view change. If you simply change the geometry of the view, the view is typically not redrawn. Instead, its existing content is adjusted based on the value in the view’s contentMode property. Redisplaying the existing content improves performance by avoiding the need to redraw content that has not changed.

Returns:

- (Object) setNeedsDisplayInRect(invalidRect)

Marks the specified rectangle of the receiver as needing to be redrawn. You can use this method or the setNeedsDisplay to notify the system that your view’s contents need to be redrawn. This method adds the specified rectangle into the view’s current list of invalid rectangles and returns immediately. The view is not actually redrawn until the next drawing cycle, at which point all invalidated views are updated. Note: If your view is backed by a CAEAGLLayer object, this method has no effect. It is intended for use only with views that use native drawing technologies (such as UIKit and Core Graphics) to render their content.You should use this method to request that a view be redrawn only when the content or appearance of the view change. If you simply change the geometry of the view, the view is typically not redrawn. Instead, its existing content is adjusted based on the value in the view’s contentMode property. Redisplaying the existing content improves performance by avoiding the need to redraw content that has not changed.

Parameters:

  • invalidRect (CGRect)

    The rectangular region of the receiver to mark as invalid; it should be specified in the coordinate system of the receiver.

Returns:

- (Object) setNeedsLayout

Invalidates the current layout of the receiver and triggers a layout update during the next update cycle. Call this method on your application’s main thread when you want to adjust the layout of a view’s subviews. This method makes a note of the request and returns immediately. Because this method does not force an immediate update, but instead waits for the next update cycle, you can use it to invalidate the layout of multiple views before any of those views are updated. This behavior allows you to consolidate all of your layout updates to one update cycle, which is usually better for performance.

Returns:

- (Object) setNeedsUpdateConstraints

Controls whether the view’s constraints need updating. When a property of your custom view changes in a way that would impact constraints, you can call this method to indicate that the constraints need to be updated at some point in the future. The system will then call updateConstraints as part of its normal layout pass. Updating constraints all at once just before they are needed ensures that you don’t needlessly recalculate constraints when multiple changes are made to your view in between layout passes.

Returns:

- (Object) setTranslatesAutoresizingMaskIntoConstraints(flag)

Sets whether the view’s autoresizing mask should be translated into constraints for the constraint-based layout system. Because the autoresizing mask naturally gives rise to constraints that fully specify a view’s position, any view that you wish to apply more flexible constraints to must be set to ignore its autoresizing mask using this method. You should call this method yourself for programmatically created views. Views created using a tool that allows setting constraints should have this set already.

Parameters:

  • flag (Boolean)

    YES if the view’s autoresizing mask should be translated into constraints for the constraint-based layout system, NO otherwise.

Returns:

- (CGSize) sizeThatFits(size)

Asks the view to calculate and return the size that best fits its subviews. The default implementation of this method returns the size portion of the view’s bounds rectangle. Subclasses can override this method to return a custom value based on the desired layout of any subviews. For example, a UISwitch object returns a fixed size value that represents the standard size of a switch view, and a UIImageView object returns the size of the image it is currently displaying. This method does not resize the receiver.

Parameters:

  • size (CGSize)

    The current size of the receiver.

Returns:

  • (CGSize)

    A new size that fits the receiver’s subviews.

- (Object) sizeToFit

Resizes and moves the receiver view so it just encloses its subviews. Call this method when you want to resize the current view so that it uses the most appropriate amount of space. Specific UIKit views resize themselves according to their own internal needs. In some cases, if a view does not have a superview, it may size itself to the screen bounds. Thus, if you want a given view to size itself to its parent view, you should add it to the parent view before calling this method.You should not override this method. If you want to change the default sizing information for your view, override the sizeThatFits: instead. That method performs any needed calculations and returns them to this method, which then makes the change.

Returns:

- (CGSize) systemLayoutSizeFittingSize(targetSize)

Returns the size of the view that satisfies the constraints it holds. Determines the best size of the view considering all constraints it holds and those of its subviews.

Parameters:

  • targetSize (CGSize)

    Indicates whether you want the smallest or largest possible size that meets the constraints. See “Fitting Size” for accepted values.

Returns:

  • (CGSize)

    The size of the view that satisfies the constraints it holds.

- (Boolean) translatesAutoresizingMaskIntoConstraints

Returns a Boolean value that indicates whether the view’s autoresizing mask is translated into constraints for the constraint-based layout system. If this is value is YES, the view’s superview looks at the view’s autoresizing mask, produces constraints that implement it, and adds those constraints to itself (the superview).

Returns:

  • (Boolean)

    YES if the view’s autoresizing mask is translated into constraints for the constraint-based layout system, NO otherwise.

- (Object) updateConstraints

Update constraints for the view. Custom views that set up constraints themselves should do so by overriding this method. When your custom view notes that a change has been made to the view that invalidates one of its constraints, it should immediately remove that constraint, and then call setNeedsUpdateConstraints to note that constraints need to be updated. Before layout is performed, your implementation of updateConstraints will be invoked, allowing you to verify that all necessary constraints for your content are in place at a time when your custom view’s properties are not changing.You may not invalidate any constraints as part of your constraint update phase. You also may not invoke a layout or drawing phase as part of constraint updating.You must call [super updateConstraints] as part of your implementation.

Returns:

- (Object) updateConstraintsIfNeeded

Updates the constraints for the receiving view and its subviews. Whenever a new layout pass is triggered for a view, the system invokes this method to ensure that any constraints for the view and its subviews are updated with information from the current view hierarchy and its constraints. This method is called automatically by the system, but may be invoked manually if you need to examine the most up to date constraints.Subclasses should not override this method.

Returns:

- (UIView) viewForBaselineLayout

Returns a view used to satisfy baseline constraints. When you make a constraint on the NSLayoutAttributeBaseline of a view, the system aligns with the bottom of the view returned by this method. The default implementation returns the receiving view. If you override this method, the returned view must be a subview of the receiver.

Returns:

  • (UIView)

    The view the constraint system should use to satisfy baseline constraints

- (UIViewPrintFormatter) viewPrintFormatter

Returns a print formatter for the receiving view. When initiating a print job, you can call this method to obtain an appropriate view print formatter object for your view. You can use the formatter object to configure the page layout options for your view during printing. Each time you call this method, you get a unique view print formatter object.For more information about how to use print formatters to configure the printing behavior of your view, see Drawing and Printing Guide for iOS.

Returns:

- (UIView) viewWithTag(tag)

Returns the view whose tag matches the specified value. This method searches the current view and all of its subviews for the specified view.

Parameters:

  • tag (Integer)

    The tag value to search for.

Returns:

  • (UIView)

    The view in the receiver’s hierarchy whose tag property matches the value in the tag parameter.

- (Object) willMoveToSuperview(newSuperview)

Tells the view that its superview is about to change to the specified superview. The default implementation of this method does nothing. Subclasses can override it to perform additional actions whenever the superview changes.

Parameters:

  • newSuperview (UIView)

    A view object that will be the new superview of the receiver. This object may be nil.

Returns:

- (Object) willMoveToWindow(newWindow)

Tells the view that its window object is about to change. The default implementation of this method does nothing. Subclasses can override it to perform additional actions whenever the window changes.

Parameters:

  • newWindow (UIWindow)

    The window object that will be at the root of the receiver's new view hierarchy. This parameter may be nil.

Returns:

- (Object) willRemoveSubview(subview)

Tells the view that a subview is about to be removed. The default implementation of this method does nothing. Subclasses can override it to perform additional actions whenever subviews are removed. This method is called when the subview’s superview changes or when the subview is removed from the view hierarchy completely.

Parameters:

  • subview (UIView)

    The subview that will be removed.

Returns: