Why does a UIButton have 3 different image properties?

A UIButton has 3 different image properties:

currentBackgroundImage currentImage imageView

What do each of them represent?

http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIButton_Class/UIButton/UIButton.html

Answers


I would say that a UIButton has two sets of images:

  1. those assigned through: setImage:forState:

  2. those assigned through setBackgroundImage:forState:

They allow you to set foreground and background images for the allowed states to a button: UIControlStateNormal, UIControlStateHighlighted, UIControlStateDisabled, UIControlStateSelected, etc. (they are described in the doc you link to, under section "Control State".)

Now, currentBackgroundImage and currentImage allow direct access to the current image (i.e., the image corresponding to the current state of the button).

On the other hand, imageView allows to have access to the UIImageView object underlying the button image, so that you can set its properties, if needed. E.g. (from the doc you link):

Although this property is read-only, its own properties are read/write. Use these properties to configure the appearance and behavior of the button’s view. For example:

    UIButton *button                   = [UIButton buttonWithType: UIButtonTypeRoundedRect];
    button.imageView.exclusiveTouch    = YES;

Need Your Help

Words Will Not Stay Inside Div

html css

I cannot seem to get my words into the div it is supposed to go in. The text Maidir Linne should go in the red box. It is basically the div labelled aboutus. I want the text Maidir Linne to be insi...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.