UIImage: Difference between revisions

From Medien Wiki
 
Line 7: Line 7:
For example a stretchable speech bubble:<br/>
For example a stretchable speech bubble:<br/>
[[File:AD_SpeachBubble.png|The Image to be used]]
[[File:AD_SpeachBubble.png| The Image to be used]]


First without this method:
First without this method:

Latest revision as of 10:45, 1 March 2012

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