Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Try this:</p> <pre><code>NSString *text1 = @"Found by "; //text of your uilabel CGSize constraint1 = CGSizeMake(320, 2000); //suppose your total width of superview is 320 CGSize size1 = [text1 sizeWithFont:[UIFont fontWithName:@"ArialMT" size:12.0] constrainedToSize:constraint1 lineBreakMode:UILineBreakModeWordWrap]; //font which are used in your "Found by" label NSString *text2 = @"The Gluten free foodie"; //text of your uibutton CGSize constraint2 = CGSizeMake(320, 2000); CGSize size2 = [text2 sizeWithFont:[UIFont fontWithName:@"Arial-BoldMT" size:12.0] constrainedToSize:constraint2 lineBreakMode:UILineBreakModeWordWrap]; //font which are used in your "The Gluten free foodie" button float finalwidth = size1.width + size2.width + 2; float centerx = 320 - finalwidth; //suppose your total width of view is 320 centerx = centerx/2.0; lblFoundBy.frame = CGRectMake(centerx, 20, size1.width, size1.height); btnThe.frame = CGRectMake(centerx + size1.width + 2, 20, size2.width, size2.height); </code></pre> <ol> <li>Find width of your label based on text of that label</li> <li>Find width of your button based on title of that button</li> <li>get total width of your label, button and space between these two.</li> <li>Subtract that total width from you uiview (superview of button and label) width (suppose 320).</li> <li>Finally you get total extra space. After that this extra space is divided by 2.</li> <li>And last, based on that set the frame (x position is important) of your label and button.</li> </ol>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload