Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Autolayout: Content hugging VS Content compression resistance priority

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 1.68k
    Comment on it

    Hi All,

    We have properties to set content according to content length and device screen size which help us to manage user interface of an application. Content hugging priority and content compression resistance priority helps you to maintain User interface of application.

    Let have an example : Place a button with top , leading , trailing and central horizontal constraint.

    1) Leading constraint priority :-  1000      Trailing constraint priority :- 1000

    Content hugging priority :-  Horizontal : 250  Vertical : 250

    Content compression resistance priority :-  Horizontal : 750  Vertical : 750

     

     

     

    2) Leading constraint priority :-  500     Trailing constraint priority :- 500

    Content hugging priority :-  Horizontal : 750  Vertical : 750

    Content compression resistance priority :-  Horizontal : 750  Vertical : 750

    As you can see above button size contracts to minimum size.

     

    3) Leading constraint priority :-  500     Trailing constraint priority :- 500

    Content hugging priority :-  Horizontal : 750  Vertical : 750

    Content compression resistance priority :-  Horizontal : 250  Vertical : 250

    First increase leading constraint constant and leading constraint constant by 50 points

    as you can see button text truncate from middle as content compression resistance is less than leading and trailing priority.

 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: