Search code examples
iosobjective-csize-classes

How to center button in Quadrant in size classes?


I have Storyboard of any any size. i want to center first,second, third, fourth button in each Quadrant. how to set constraints? with respect to UILable.

enter image description here


Solution

  • Take 4 view for 4 button

    (right top) View 1 - Trailing = 0 and Top = 0 to superview,horizontal space = 0 to view 2 and vertical space = 0 to view 4

    (left top) View 2 - Leading = 0 and top = 0 to superView

    (left bottom) View 3 - leading = 0 and bottom = 0 to superview,horizontal space = 0 to view 4 and vertical space = 0 to view 2

    (right bottom) View 4 - Trailing = 0 and Bottom = 0 to superview

    Equal height and width for all view

    put each button in each view with horizontal and vertical centre with superview

    Second Option : set every button horizontal and vertical center of view and set multiplier as below

    for button 1 (right-Top)

    center x: multiplier = 1.5
    center y: multiplier = 0.5
    

    for button 2 (Left-Top)

    center x: multiplier = 0.5
    center y: multiplier = 0.5
    

    for button 3 (Left-Bottom)

    center x: multiplier = 0.5
    center y: multiplier = 1.5
    

    for button 4 (right-Bottom)

    center x: multiplier = 1.5
    center y: multiplier = 1.5