Standard "Delete" button?

Discussion in 'Mac Programming' started by caldwelljason, Jul 10, 2008.

  1. caldwelljason macrumors member

    Joined:
    Jul 9, 2008
    #1
    I need a red "Delete" button at the bottom of my view, like the calendar has when editing an event.

    I'm trying to figure out how to get the nice, rounded, gradient-filled red button as the background. Does that exist anywhere that I have access to? Is it somehow a style of a button? I can't seem to find it.

    Or do I need to create an image and set it as the background image for my button?
     
  2. liptonlover macrumors 6502a

    Joined:
    Mar 13, 2008
    #2
    you could...
    a) create a red button shaped image that says "delete"
    b) set the button to have no frame.
    c) set the buttons' image to the image.
     
  3. caldwelljason thread starter macrumors member

    Joined:
    Jul 9, 2008
    #3
    Solution

    Hope this helps someone else!

    I ended creating a default button image and a pressed button image. Then I create a UIImage* using stretchableImageWithLeftCapWidth to stretch the image across the entire button. Having created the UIImage*, I set that as the background on the button with

    [myButton setBackgroundImage:myPressedImage forState:UIControlStateHighlighted];

    and

    [myButton setBackgroundImage:mydefaultImage forState:UIControlStateNormal];

    Works like a charm. :cool:

    I actually created a factory class that creates the buttons for me in a single method call so that I can control the look of all the buttons in the app in a single place.
     

Share This Page