Deprecated UIImage Methods

A method identified as deprecated has been superseded and may become unsupported in the future.

Deprecated in iOS 5.0

leftCapWidth

The horizontal end-cap size. (read-only) (Deprecated in iOS 5.0. Use the capInsets property instead.)

@property(nonatomic, readonly) NSInteger leftCapWidth
Discussion

End caps specify the portion of an image that should not be resized when an image is stretched. This technique is used to implement buttons and other resizable image-based interface elements. When a button with end caps is resized, the resizing occurs only in the middle of the button, in the region between the end caps. The end caps themselves keep their original size and appearance.

This property specifies the size of the left end cap. The middle (stretchable) portion is assumed to be 1 pixel wide. The right end cap is therefore computed by adding the size of the left end cap and the middle portion together and then subtracting that value from the width of the image:

rightCapWidth = image.size.width - (image.leftCapWidth + 1);

By default, this property is set to 0, which indicates that the image does not use end caps and the entire image is subject to stretching. To create a new image with a nonzero value for this property, use the stretchableImageWithLeftCapWidth:topCapHeight: method.

Availability
  • Available in iOS 2.0 and later.
  • Deprecated in iOS 5.0.
Declared In
UIImage.h

topCapHeight

The vertical end-cap size. (read-only) (Deprecated in iOS 5.0. Use the capInsets property instead.)

@property(nonatomic, readonly) NSInteger topCapHeight
Discussion

End caps specify the portion of an image that should not be resized when an image is stretched. This technique is used to implement buttons and other resizable image-based interface elements. When a button with end caps is resized, the resizing occurs only in the middle of the button, in the region between the end caps. The end caps themselves keep their original size and appearance.

This property specifies the size of the top end cap. The middle (stretchable) portion is assumed to be 1 pixel wide. The bottom end cap is therefore computed by adding the size of the top end cap and the middle portion together and then subtracting that value from the height of the image:

bottomCapHeight = image.size.height - (image.topCapHeight + 1);

By default, this property is set to 0, which indicates that the image does not use end caps and the entire image is subject to stretching. To create a new image with a nonzero value for this property, use the stretchableImageWithLeftCapWidth:topCapHeight: method.

Availability
  • Available in iOS 2.0 and later.
  • Deprecated in iOS 5.0.
Declared In
UIImage.h

stretchableImageWithLeftCapWidth:topCapHeight:

Creates and returns a new image object with the specified cap values. (Deprecated in iOS 5.0. Deprecated. Use the resizableImageWithCapInsets: instead, specifying cap insets such that the interior is a 1x1 area.)

- (UIImage *)stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight
Parameters
leftCapWidth

The value to use for the left cap width. Specify 0 if you want the entire image to be horizontally stretchable. For a discussion of how a non-zero value affects the image, see the leftCapWidth property.

topCapHeight

The value to use for the top cap width. Specify 0 if you want the entire image to be vertically stretchable. For a discussion of how a non-zero value affects the image, see the topCapHeight property.

Return Value

A new image object with the specified cap values.

Discussion

During scaling or resizing of the image, areas covered by a cap are not scaled or resized. Instead, the 1-pixel wide area not covered by the cap in each direction is what is scaled or resized. This technique is often used to create variable-width buttons, which retain the same rounded corners but whose center region grows or shrinks as needed.

You use this method to add cap values to an image or to change the existing cap values of an image. In both cases, you get back a new image and the original image remains untouched.

Availability
  • Available in iOS 2.0 and later.
  • Deprecated in iOS 5.0.
Declared In
UIImage.h