The -initWithFrame:(CGRect)frame method is a UIView method on iOS. This method initializes and returns a newly allocated view object with the specified frame rectangle.
This method initializes and returns a newly allocated view object with the specified frame rectangle.
- (id)initWithFrame:(CGRect)aRect
Parameters:
- aRect:
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.
- Return Value:
An initialized view object or nil if the object couldn't be created.
More info:
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.
Available in iOS 2.0 and later.