Search code examples
xcodenslayoutconstraint

Xcode 9 - Labels overlapping on iPhone SE Screen size


I don't know what constraint I need to add to prevent the labels from overlapping on a smaller screen size. I've tried placing a horizontal constraint between the two labels, however on larger screen sizes, the symbol label doesn't stay at the end of the view.

These are the constraints I've made for the two labels.
https://i.sstatic.net/t2qzm.png - Constraint 1
https://i.sstatic.net/t2qzm.png - Constraint 2

This is what it looks like on iPhone SE.
https://i.sstatic.net/YZ7IX.png


Solution

  • Easy Way

       Use Stackview and add both of your view 
    

    With Constraints

    To your left label (Where I can ..) add

    Leading , Top , Bottom , Trailing (>= Relation) (with right side view which has play icon)
    

    To your ride side view (which has play icon) add

    Top, Bottom, Trailing (= relation ) (with super view) , Width (Whatever your constant with >= Relation )
    

    In your first label you can set number of lines 2 and line break mode to word wrap to encounter ... in small devices

    Hope it is helpful