Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3845768
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:17:42+00:00 2026-05-19T16:17:42+00:00

I am building an app in which I need to resize the button as

  • 0

I am building an app in which I need to resize the button as per the title length. I wrote the following code

`UIButton *newButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];

newButton.backgroundColor = [ UIColor clearColor];
newButton.titleLabel.backgroundColor = [ UIColor whiteColor];
[newButton setTitle:@"devsri" forState:UIControlStateNormal];
newButton.titleLabel.textColor = [ UIColor blackColor];

CGSize expectedLabelSize = [newButton.titleLabel.text sizeWithFont:newButton.titleLabel.font]; 
newButton.frame = CGRectMake(xBase, yBase, expectedLabelSize.width, expectedLabelSize.height);

The above code do resize the table but the button no more remains round rectangle in view. Kindly let me know what is wrong in the above code.

Thanks in advance!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:17:42+00:00Added an answer on May 19, 2026 at 4:17 pm

    I got the bug in here. I was initializing the frame with the size of the titlelabel that was eventually bigger than the original button in width. Thus the line

    newButton.frame = CGRectMake(xBase, yBase, expectedLabelSize.width, expectedLabelSize.height);
    

    as

    newButton.frame = CGRectMake(xBase, yBase, expectedLabelSize.width + 15, expectedLabelSize.height);
    

    This will widen the button enough to accomodate the new size of the label.

    🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an app for which I need to set up cron jobs.
I'm am building a web app and need a text to speech which highlights
I am building an android app in which I need to show the list
I am building an android app for which I need to check the sync
I'm building a web-based chat app which will need to make an AJAX request
I am building an examination app, in which i need users to stay on
I am building an app which will be distributed using enterprise distribution.So we need
I'm building a highly scalable app, and I need to know which data type
I am building an app in which I need to backtrack some datas. To
I'm building a Django app in which I need to represent gender (male/female) for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.