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

  • Home
  • SEARCH
  • 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 270589
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:01:32+00:00 2026-05-12T00:01:32+00:00

I’m new to programming for the iPhone and i’m wondering: how extensible are the

  • 0

I’m new to programming for the iPhone and i’m wondering: how extensible are the various controls? Let’s take the button as an example:

  • can i change the background graphic?
  • can i make it grow larger when i press on it?
  • can i change the font?
  • can i use a custom font?
  • can i use a button graphic in place of text?
  • 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-12T00:01:32+00:00Added an answer on May 12, 2026 at 12:01 am

    In general, yes to all your questions. You can subclass the various UI* classes that make up the Cocoa touch controls just like any other classes, and add your own custom functionality in the appropriate methods. The only tricky part is figuring out where exactly your code should go.

    Let’s look at your UIButton example, and walk through what you want to do with it.

    Background image

    The UIButton class already has a method setBackgroundImage:forState: that lets you change the UIImage the button displays when it’s in one of several states, such as Normal, Highlighted, Disabled, and so on.

    For example, to change the image the button displays as a normal background to “backgroundImage.png”, which is an image file in your application’s bundle:

    //Presuming you have some UIButton *button:
    UIImage *bgImage = [UIImage imageNamed:@"backgroundImage.png"];
    [button setBackgroundImage:bgImage forState:UIControlStateNormal];

    Growing larger

    You can change the button’s frame (an inherited property from UIView) by adding a method to do so in the view controller .m file that manages the button, then adding that method as an action for a control event on the button.

    Let’s say you want to double the size of the button. In viewDidLoad: or somewhere similar, add the following code:

    [button addTarget:self action:@selector(growButton) 
                 forControlEvents:UIControlEventTouchDown];

    Then create a method growButton with the following code:

    - (void)growButton {
        CGRect currentFrame = button.frame;
        CGRect newFrame = CGRectMake(currentFrame.origin.x - currentFrame.size.width / 2,
                                     currentFrame.origin.y - currentFrame.size.height / 2,
                                     currentFrame.size.width * 2,
                                     currentFrame.size.height * 2);
        button.frame = newFrame;
    }

    This doubles your button’s size while keeping its center the same. (Be careful your button doesn’t grow over the edge of your view when you do this.)

    Changing the font

    Simply change the font property of the UIButton – set it to a new instance of UIFont, like in this example:

    button.font = [UIFont systemFontOfSize:16.0];

    This changes the button’s font to the system’s font with size 16.

    Custom font

    This is a somewhat trickier question, as I’m pretty sure you can’t load your own custom font files, even if you include them in your app bundle. You can, however, change the default font of a control by using UIFont’s fontWithName:size: class method. All the font names are available through UIFont’s familyNames and fontNamesForFamilyName: methods.

    Button graphics instead of text

    This is the simplest of the five – just don’t set the text on the button, but instead set a background image for UIControlStateNormal (see above).

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
i got an object with contents of html markup in it, for example: string
I need to clean up various Word 'smart' characters in user input, including but

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.