[Mono-bugs] [Bug 549434] New: Custom button background image on highlight not taking effect

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Oct 22 20:48:48 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=549434


           Summary: Custom button background image on highlight not taking
                    effect
    Classification: Mono
           Product: MonoTouch
           Version: SVN
          Platform: 64bit
        OS/Version: Mac OS X 10.6
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Class Libraries
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: sim_paw at hotmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: Community User


Description of Problem:

When creating a custom button with background images for normal and highlighted
states the image for highlighted state does not take effect.

The following two methods within ButtonsViewController are used to generate the
button in question:

static UIButton ButtonWithTitle (string title, RectangleF frame, UIImage image,
UIImage imagePressed, bool darkTextColor)
{
    var button = new UIButton (frame) {
        VerticalAlignment = UIControlContentVerticalAlignment.Center,
        HorizontalAlignment = UIControlContentHorizontalAlignment.Center,
        BackgroundColor = UIColor.Clear
    };

    button.SetTitle (title, UIControlState.Normal);
    if (darkTextColor)
        button.SetTitleColor (UIColor.Black, UIControlState.Normal); else
        button.SetTitleColor (UIColor.White, UIControlState.Normal);

    var newImage = image.StretchableImage (12, 0);
    button.SetBackgroundImage (newImage, UIControlState.Normal);
    var newPressedImage = image.StretchableImage (12, 0);
    button.SetBackgroundImage (newPressedImage, UIControlState.Highlighted);

    button.Tag = kViewTag;
    // To support reusable cells
    button.TouchDown += delegate { Console.WriteLine ("The button has been
touched"); };

    return button;
}

UIButton GrayButton ()
{
    var background = UIImage.FromFile ("images/whiteButton.png");
    var backgroundPressed = UIImage.FromFile ("images/blueButton.png");
    var frame = new RectangleF (182f, 5f, 106f, 40f);

    return ButtonWithTitle ("Gray", frame, background, backgroundPressed,
true);
}


Steps to reproduce the problem:
1. Download sample file
http://www.go-mono.com/archive/monotouch-samples-2009-09-11.tar.gz
2. Extract and load the monocatalog-md project in mono develop.
3. Build and run project on simulator.
4. Select the "Buttons" table item on top of the list.
4. Press the button labeled "Gray".  


Actual Results:
The button state does not appear to change, i.e. the button remains gray.
However from console messages the TouchDown event is being processed as
expected. 

Expected Results:
The button should turn blue when pressed.

How often does this happen? 
Always.


Additional Information:

Snow Leopard 10.6.1
iPhone SDK 3.1.2 with Xcode 3.2.1

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list