IOS development tutorial -- How to Use the image at, ios --
Prepare an image in advance:
UIImage * image = [UIImageimageNamed: @ "red.png"];
This can be used before iOS 5.0:
NSInteger leftCapWidth = image. size. width * 0.5f;
NSInteger topCapHeight = image. size. height * 0.5f;
Image = [image stretchableImageWithLeftCapWidth: leftCapWidthtopCapHeight: topCapHeight];
In iOS 5.0, this can be used as follows:
CGFloat top = 8; // height of top Cover
CGFloat bottom = 8; // End Cover height
CGFloat left = 8; // width of the left End Cover
CGFloat right = 8; // right End Cover width
UIEdgeInsets insets = UIEdgeInsetsMake (top, left, bottom, right );
// Assign a value after scaling
Image = [image resizableImageWithCapInsets: insets];
This can be used in iOS6.0:
CGFloat top = 12; // height of top Cover
CGFloat bottom = 12; // End Cover height
CGFloat left = 10; // width of the left End Cover
CGFloat right = 10; // right End Cover width
UIEdgeInsets insets = UIEdgeInsetsMake (top, left, bottom, right );
// Specify the stretch mode and assign a value after scaling.
Image = [image resizableImageWithCapInsets: insetsresizingMode: UIImageResizingModeStretch];
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.