Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Bounds and Frames in iOS

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 499
    Comment on it


    Hi Readers,


    This Post is to tell about the BOUND and FRAME in ios.


    BOUND:


    The bounds property of a view defines the size of the view and its position in the view's own coordinate system. This means that in most cases the origin of the bounds of a view are set to {0,0}. The view's bounds is important for drawing the view.


    FRAME:


    The frame of a view is a structure, a CGRect, that defines the size of the view and its position in the view's superview, the superview's coordinate system.


    BELOW EXAMPLE WILL MAKE THE DIFFERENCE MORE CLEAR


    Imagine a view that has a size of 100x100 (width x height) positioned at 25,25 (x,y) of its superview. The following code prints out this view's bounds and frame: // This method is in the view controller of the superview


    1. - (void)viewDidLoad
    2. {
    3. [super viewDidLoad];
    4.  
    5. NSLog(@"bounds.origin.x: %f", label.bounds.origin.x);
    6. NSLog(@"bounds.origin.y: %f", label.bounds.origin.y);
    7. NSLog(@"bounds.size.width: %f", label.bounds.size.width);
    8. NSLog(@"bounds.size.height: %f", label.bounds.size.height);
    9.  
    10. NSLog(@"frame.origin.x: %f", label.frame.origin.x);
    11. NSLog(@"frame.origin.y: %f", label.frame.origin.y);
    12. NSLog(@"frame.size.width: %f", label.frame.size.width);
    13. NSLog(@"frame.size.height: %f", label.frame.size.height);
    14.  
    15. }

    And the output of this code is:


    1. bounds.origin.x: 0
    2. bounds.origin.y: 0
    3. bounds.size.width: 100
    4. bounds.size.height: 100
    5.  
    6. frame.origin.x: 25
    7. frame.origin.y: 25
    8. frame.size.width: 100
    9. frame.size.height: 100


    Thanx for Reading

    Keep Coding

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: