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 7851123
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:05:26+00:00 2026-06-02T19:05:26+00:00

Is there a convenient way to make a button with a badge? Not on

  • 0

Is there a convenient way to make a button with a badge? Not on the icon… I want to do it within the app. A button or an image with a badge selected by the program. Or do I have to build a library of photoshop images?

  • 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-06-02T19:05:27+00:00Added an answer on June 2, 2026 at 7:05 pm

    You’ll need to use resizableImageWithCapInsets to achieve this without a library of photoshop images. There are some great threads (here and here) that explain its use.

    Here’s an example I just made to give you an idea:

    //Create a label (width/height not important at this stage)
    UILabel *yourLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 1, 1)];
    yourLabel.text = @"7+";
    [yourLabel sizeToFit];
    
    CGRect labelFrame = yourLabel.frame;
    
    //Here we create a UIImage that is resizable, but will not resize the areas concerned with the cap insets you've defined
    UIImage *badgeImage = [[UIImage imageNamed:@"badge.png"]resizableImageWithCapInsets:UIEdgeInsetsMake(5, 5, 5, 5)];
    UIImageView *badgeImageView = [[UIImageView alloc]initWithImage:badgeImage];
    
    badgeImageView.contentMode = UIViewContentModeScaleToFill;
    badgeImageView.backgroundColor = [UIColor clearColor];
    
    labelFrame.size.width += 5; //This is the 'padding' on the right and left (added together)
    //If your badge edges are completely circular then you don't want to change the height, but if they're not then go ahead in the same way with the width. If your badge has a static height, you'll need to make sure the font size doesn't exceed this height; better start off with a small font-size
    
    badgeImageView.frame = labelFrame; //The badge is now the right width with padding taken into account
    
    //Center the label on the badge image view
    yourLabel.center = CGPointMake(badgeImageView.frame.size.width/2, badgeImageView.frame.size.height/2);
    
    //Finally we add the label to the badge image view
    [badgeImageView addSubview:yourLabel];
    //Add your badge to the main view
    [self.view addSubview:badgeImageView];
    
    [badgeImageView release];
    [yourLabel release];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a convenient way to generate code from any new view controllers I've
Is there a convenient way to calculate percentiles for a sequence or single-dimensional numpy
Is there a convenient way to do this for my extension? I know I
Is there any convenient way to type in braces in Math in Latex? Especially
Is there any convenient way to take an array/set of objects and create a
Is there a way to make LogCat's output to appear in Console view in
Is there any way in Spotlight to have a folder open in a Terminal
Is there an easy way to make an ObjectContext public in debug mode and
Is there any way to make a segment control invisible while still being clickable?
in languages like PHP or Python there are convenient functions to turn an input

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.