Inherits from NSObject
Declared in AKButtonImageCoordinator.h
AKButtonImageCoordinator.m

Overview

The AKImageCoordinator class is a convenient way to ensure that specific image renderers will produce appropriately-sized images for displaying in a button.

Typically, you will have a reference to an AKButtonImageCoordinator in a UIViewController class. Then, in the -viewWillAppear: method of your view controller, you’ll call addButton: on the button coordinator, which will take care of setting the appropriate image values. Similarly, in your implementation of -viewWillDisappear:, you’ll call removeButton: with the button to absolve the button image coordinator of responsibility for rendering images for off-screen views.

The button image coordinator maintains a reference to two image renderers: onImageRenderer and offImageRenderer. The onImageRenderer corresponds to the button’s highlighted control state, and the offImageRenderer corrsponds to the button’s normal control state.

Tasks

Configuring the Button Image Coordinator

  •   onImageRenderer

    An image renderer for the “on” state, corresponding to the button’s highlighted control state.

    property
  •   offImageRenderer

    An image renderer for the “off” state, corresponding to the button’s normal control state.

    property

Adding and Removing Buttons

  • – addButton:

    Adds a button to the button image coordinator. When the button’s frame changes, the button image coordinator will automatically re-render the images.

  • – removeButton:

    Removes a button from the button image coordinator. This will not clear the current images in the button, but will prevent the button image coordinator from re-rendering images if the button’s frame changes.

Properties

offImageRenderer

An image renderer for the “off” state, corresponding to the button’s normal control state.

@property (strong, nonatomic) AKImageRenderer *offImageRenderer

Declared In

AKButtonImageCoordinator.h

onImageRenderer

An image renderer for the “on” state, corresponding to the button’s highlighted control state.

@property (strong, nonatomic) AKImageRenderer *onImageRenderer

Declared In

AKButtonImageCoordinator.h

Instance Methods

addButton:

Adds a button to the button image coordinator. When the button’s frame changes, the button image coordinator will automatically re-render the images.

- (void)addButton:(UIButton *)button

Parameters

button

The button for which the image coordinator will render images.

Declared In

AKButtonImageCoordinator.h

removeButton:

Removes a button from the button image coordinator. This will not clear the current images in the button, but will prevent the button image coordinator from re-rendering images if the button’s frame changes.

- (void)removeButton:(UIButton *)button

Parameters

button

The button for which the button image coordinator will no longer render images.

Declared In

AKButtonImageCoordinator.h