UIImage

From Medien Wiki

UIImage

Method stretchableImageWithLeftCapWidth:topCapHeight:

If you want to have a stretchable UIView with your own image you can use the object method stretchableImageWithLeftCapWidth:topCapHeight: from an UIImage.

For example a stretchable speech bubble:

The Image to be used

First without this method:

UIImage* img=[UIImage imageNamed:@"SpeachBubble"];
UIImageView* imgView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 500, 300)];
imgView.image=img;
[self.view addSubview:imgView];	
[imgView release];

The result is:
The result

Now with this method:

UIImage* img=[[UIImage imageNamed:@"SpeachBubble"] stretchableImageWithLeftCapWidth:90 topCapHeight:80];
UIImageView* imgView=[[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 500, 300)];
imgView.image=img;
[self.view addSubview:imgView];	
[imgView release];

Now the result is:
The result