Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to implement the Auto Layout Contraint through Code

    • 0
    • 3
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 287
    Comment on it

    Hi Readers,


    This Post is just a brief introduction about How we can implement Autolayout Contraints through coding.

    Now,Before moving ahead with the topic let us have a brief about AutoLayout.


    WHAT IS AUTOLAYOUT...??


    Auto Layout is a way to define relationships between elements. In Auto Layout we can describe how views and the controls are related to each other because of it's flexible and powerful system. We can get an incredible control over layout, with a wide range of customization, and create a perfect interface only with the help of Auto Layout.


    NOW,LETS IMPLEMENT AUTOLAYOUT THROUGH CODE---!!


    * Creating a Contraint


     NSLayoutConstraint *myConstraint =[NSLayoutConstraint      
                            constraintWithItem:mylabel
                            attribute:NSLayoutAttributeCenterY
                            relatedBy:NSLayoutRelationEqual
                            toItem:superview
                            attribute:NSLayoutAttributeCenterY
                            multiplier:1.0
                            constant:0];
    [superview addConstraint:myConstraint];
    

    Above,we have created a Constraint named myContraint on a label named my label


    * Removing a Contraint


    [superview removeconstraint:myConstraint];
    

    if you want to remove a contraint simply use the above line .

    Thanx For Reading
    Keep Coding..:)

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: