IPhone button sizing

Does anyone know how to control the size of navigation bar buttons?
I'm creating a button with the pen-and-paper image UIImageNameMessageCompose. (Thanks Chippydip, for telling me about these system image constants.) Here's the code I used (pretend the curly braces are square):
button = {UIButton buttonWithType:UIButtonTypeNavigation};
{button setImage:{UIImage imageNamed:UIImageNameMessageCompose} forStates:...};
The problem is, instead of a pretty square-ish button like you see in the Mail and Text apps on the iPhone, I get a huge ugly wide button. There seems to be a minimum margin imposed around the image. Also, the image is not centered vertically in the button.
Changing the frame size of the button has no effect. I see there are properties of buttons called "contentInset" and "imageInset" but I'm not sure what these do. Does anyone know how to make my button look like the ones in Mail and Text?
Thanks,
Eliza

I've solved the problem. It's a matter of just setting the button's frame by hand. When I thought that wouldn't work before, it was because I was first setting the frame, then setting the image. When you set the button image it re-sets the frame to be 20 pts wider than the image.
So you just have to set the image first, then set the frame.
For those interested, the following code makes a nice square-ish "compose message" button in the nav bar (the content edge inset fix centers the image vertically):
UIButton *button = {UIButton buttonWithType:UIButtonTypeNavigation};
{button setImage:{UIImage imageNamed:UIImageNameMessageCompose forStates:UIControlStateNormal};
button.contentEdgeInsets = UIEdgeInsetsMake(-2, 0, 2, 0);
button.frame = CGRectMake(0, 0, 35, 30);
-eliza

Similar Messages

  • HT1414 there is no "check for UPDATE"  or "restore ur iphone "  buttons on main screen of itunes..

    hi
    i have iphone 4s runing on 7.0.4 ios
    i recently updated my windows to 8.1.
    earlier i used to use windos xp.
    as soon as i started windows 8.1,  there is no "check for UPDATE"  or "restore ur iphone "  buttons on main screen of itunes..
    how shd i update or restore my iphone now..?
    is there any settings
    regards
    jayesh

    Windows doesn't detect iPhone: http://support.apple.com/kb/ts1538

  • My iphone button not working

    hi there,
    i got iphone 4G, both buttons are not working
    ,upper one doesnt work

    Settings > General > Accessibility > AssistiveTouch > Toggle On
    This feature can act as most of the iPhone buttons. Home or Sleep/Wake etc. It would help us if we knew which buttons your talking about.
    Hope that helps

  • My iphones buttons are not working and it shows a black screen whith apple logo on it what should i do now?

    my iphones buttons are not working and it shows a black screen whith apple logo on it what should i do now?
    and i have to post sth importent on instagram tonight so its ergent please help....

    Greetings motahare,
    After reviewing your post, I have located an article that can help with iOS device issues. It contains a number of troubleshooting steps and helpful advice for the issue you are experiencing:
    If your iPhone, iPad, or iPod touch doesn't respond or doesn't turn on - Apple Support
    Thank you for contributing to Apple Support Communities.
    Best,
    Bobby_D

  • HT1386 I don't have the iPhone button, as illustrated in the first picture. I've tried the tips that are mentioned in the first few steps and still nothing. My phone won't sync at all! I'm not completely computer illiterate; but, I am not well versed eith

    I don't have the iPhone button, as illustrated in the first picture. I've tried the tips that are mentioned in the first few steps and still nothing. My phone won't sync at all! I'm not completely computer illiterate; but, I am not well versed either. Could someone please tell me what I need to do to bring this back so I can sync my phone and laptop (windows op system).

    The screen-shot is on a Mac computer. It is very similar in Windows iTunes.  Have a look at this set of instructions instead.
    http://support.apple.com/kb/ph12313

  • IPhone button not working

    My iPhone4 home button not working. Pressing the home and on/off button together does not bring up a dark screen with the apple logo. I have a laptop with window's 7 - ITunes not working and the apple website's download button not responding.
    I am due an upgrade soon and was considering an iPhone again, but this inconvenience of not working and the trouble of accessing the software is giving me second thoughts of going for an iPhone again.

    Settings > General > Accessibility > AssistiveTouch > Toggle On
    This feature can act as most of the iPhone buttons. Home or Sleep/Wake etc. It would help us if we knew which buttons your talking about.
    Hope that helps

  • On/off iphone button

    My sleep/power button on my iphone 4 has stuck in the down position and now will no longer work. I called apple and they quoted me $149 to fix it. Does anyone have a less expensive way of fixing this problem?
    Thanks!

    Make an appointment at the genius bar of your local Apple Store.
    IF there is any physical damage to the phone, cracked screen, etc. then the warranty is void. It doesn't matter what caused the lock button to fail, if the phone is damaged, it's not covered.

  • [iPhone] - button press even firing multiple times

    Hi - first post here, so sorry if it's dumb (doesn't seem to have been answered previously, by searching)...
    I have an iPhone app, with a button. In my ViewController code I have an IBAction, which I've linked up with the Touch Up Inside event. The Action function increases an integer score by 50, and then updates a label to display the new score.
    When I run this, the score goes up in increments of 200 - implying the button even is being triggered multiple (four) times per click.
    Is that normal / is there any obvious reason why this might happen? I can post code if that's useful...
    Thanks,
    Muzz

    Hi Ace, and wecome to the Dev Forum!
    Acemuzzy wrote:
    When I run this, the score goes up in increments of 200 - implying the button even is being triggered multiple (four) times per click.
    No need to guess. Add a log statement as the first line of your action method like this:
    - (IBAction)incrementScore:(id)sender {
    NSLog(@"incrementScore: sender=%@", sender);
    The above will print one line in your Debugger Console window (Run->Dubugger Console) each time the method runs. It's very unlikely that your button is sending more than one action message for each Touch Up Inside event. The console log should tell us exactly who is calling your action method and how many times.
    Is that normal
    No.
    is there any obvious reason why this might happen?
    My three top guesses would be: 1) The code in your action method isn't doing what you think; 2) The action method is being called from more than one object; 3) You hooked up the button so that some of its other events (such as Touch Down or Touch Down Repeat) are also connected to your method.
    I can post code if that's useful...
    Yes, if none of my comments lead you to a solution please post the relevant code. To format code in this forum, please take a look at the first, yellow alert message on the topics page. You can see how your code will appear by clicking the Preview tab above the Reply editor panel. If and when your question is resolved, here's how to close your thread: [http://discussions.apple.com/help.jspa#answers].
    - Ray

  • Warm iphone button doesn't work?

    Today I was using Navigon for a large portion of the day, and the iphone was charging as well. The phone was quite warm. I noticed that the button didn't work well. I actually had to reset the phone several times. Now that I'm home and the phone has cooled, it works better. Is this a known problem?

    Yes, I have checked the mute button. I have toggled between the up and down buttons, to no avail. Looks like I need to go to the Apple store -ugh! Thanks

  • IPhone buttons on Microsoft stop working until hard reset

    I have a brand new iPhone 5s which shipped with 7.0.4 so I did a fresh install of 7.0.6 (not an update) its not even two weeks old however at times the buttons on the earpods will stop working and I have to do a hard reset to get them to work. I am unplugging and plugging the earpods several times as my Kenwood stereo in my jeep connects via USB for my music and the cord for my ear pods dangling tends to get in the way of my hands when turning the wheel. that's when I notice it stops working sometimes when I plug it back in. I have a life proof case with that screw in waterproof headphone adapter I take in and out of when unplugging as well... the headset and microphone work when plugged in, the buttons will just stop working

    Did you try to reset your iPhone? Hold down Power and Home buttons together until Apple logo appears.

  • My 2 iphone buttons are not working...can i repair it?

    Two days ago my iphone lock button stop working...i can't lock my iphone.Furthermore my home button is stiil working but i have to push it realy hard.Can i sent my iphone 4 to apple and repair the problem?

    You can contact Apple support to get it serviced: Apple - Support - Service Answer Center
    If your phone is already out of warranty, here are your service options, part of the article mentioned above:
    Out-of-Warranty Service
    If you own an iPhone that is ineligible for warranty service but is eligible for Out-of-Warranty (OOW) Service, Apple will service your iPhone for the Out-of-Warranty Service fee listed below.
    iPhone model
    Out-of-Warranty Service
    iPhone 4S
    $199
    iPhone 4, iPhone 3GS,
    iPhone 3G, Original iPhone
    $149
    You can also search the Internet for 3rd party repair

  • Iphone button stopped working, apple store could not fix it for me!

    Hey Guys!
    I am a pure apple user since 2007. I have owned ipods, ipads,iphones and macbooks. I have always been satisfied by apple's quality products. If any problem occured in the past it was easily fixed by either getting a replacement product or fixing the minor issues but this time visit to Apples Genius bar in China, Beijing disapointed me and loosened my trust on Apple products for future. I own and iphone 5 US factory unlocked version. I have been using it for 4 months and since the beginning the power button has caused me problems. Eventually its stopped working so as always I took it to the apple store Sanlitun in beijing to get it fixed. At first they denied to take for repiars excusing it to be a US model which could not be fixed due to difference in Logic board. I requested them to have a look at the button if it could be fixed without changing the logic board. I also requested them to replace it if it could not be fixed. They mentioned that US model cannot be replaced because of difference in Bands. I also mentioned that waiting for a little longer was also possible if they could send it for me to a place it could be fixed but they simply refused. After keeping it for 2 days there was no solution. It seemed they did not even attempt to open and have a look as my files and protective films were all intact. If anyone has faced a similar issue kindly let me know what to do next?
    If this time its not fixed i ll be very disapointed by apples international warrnaty which no longer has a meaning of covering it worldwide.
    Hope Apple satisfies me by finding a solution.
    Thanks
    Cheenu Khan

    Cheenukhan wrote:
    All apple products include International warranty!
    Incorrect...
    Apple Warranty
    http://www.apple.com/legal/warranty/
    "Choose a product" and then "Choose a region"
    iPhone Warranty  >  The warranty is only valid in the country of original purchase.
    With this exception...
    http://www.apple.com/uk/legal/statutory-warranty/

  • HT1414 When I hit the restore my iPhone button it tells me to go to iCloud on my phone and shut off find my phone.  I can't access my phone at all it is completely black.

    When I hit the restore button it tells me to go iCloud on my phone but I cannot access my phone it is completely black

    Seems that the Activation Lock feature is activated, check these articles about it:
    iCloud: Find My iPhone Activation Lock in iOS 7
    iCloud: Remove your device from Find My iPhone

  • IPhone button question

    How come the iPod touch has it's own contacts button on the main screen but iPhone makes you go into the phone button? Sometimes I just want contact information and not want to call them!
    What should be the other 3 buttons on the main screen?
    Hal

    Perhaps with a further software update, they will give us the option to choose which icons we want on our main screen - especially after they add more features and the main screen gets filled up.
    This option is already available for the iPod portion of the menu. You can change the default icons that appear at the bottom of the iPod page (Playlists, Artists, Songs, Videos, More). Select More, then click on Edit in the upper left hand corner. A Configure screen will come up. Drag the icon you want to add on top of the icon you want to replace and you're done.
    Since this feature is available in the iPod section, it seems likely that they will add it to other parts of the iPhone at a later date. One of the beauties of the iPhone is that it is software driven. Our iPhones will be continually brought up to date as improvements are made instead of becoming obsolete as most cell phone do. Hardware improvements are another matter (no 3G without buying a new iPhone when they come out) but just about everything else should be updatable.

  • IPhone button images

    Does anyone know how I might get my hands on the .png files that contain the standard iPhone application button images? (Not the application icons, but the buttons that appear on toolbars and navigation bars within applications.)
    Examples:
    - the image of an eye that appears on a button on the toolbar in the google maps application
    - the image of a pencil in a square that appears on buttons in the mail application and the text-message application
    - the triangular up,down,left,right arrows that appear in the mail app and the safari app
    - the '+' button that appears in a bunch of apps
    I was able to find the '+' button image because its .png file was included with one of the sample apps apple distributed (the SQLite app). But I'm stuck on the others. In particular, I'd like to find the image of a pencil in a box and the image of an eye. I could draw my own but they wouldn't turn out as good, and since apple is so big on consistency I would have thought they might make them available somewhere.
    Thanks,
    Eliza

    There are a couple of those type of images made available through the SDK. Check the UIImage documentation. Toward the bottom of the page is a section called "System Images" which contains these:
    UIKIT_EXTERN NSString * const UIImageNameMessageCompose;
    UIKIT_EXTERN NSString * const UIImageNameRefresh;
    UIKIT_EXTERN NSString * const UIImageNameMagnifyingGlass;
    UIKIT_EXTERN NSString * const UIImageNameLightInfo;
    I'm not sure if any of those are what you are looking for, but its worth checking out at least. I'm a little surprised that there aren't more images in the list, but perhaps more will be added before the official SDK release in June?

Maybe you are looking for