UIImage: Difference between revisions

From Medien Wiki
(Created page with "== UIImage == === Method stretchableImageWithLeftCapWidth:topCapHeight: === If you want to have a stretchable UIView with your own image you can use the object method stretcha...")
 
Line 5: Line 5:
If you want to have a stretchable UIView with your own image you can use the object method  stretchableImageWithLeftCapWidth:topCapHeight: from an UIImage.
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:
For example a stretchable speech bubble:<br/>
[[File:AD_SpeachBubble.png]]
[[File:AD_SpeachBubble.png|The Image to be used]]


First without this method:
First without this method:
Line 16: Line 17:
[imgView release];</source>
[imgView release];</source>


The result is:
The result is:<br/>
[[File:SPEACHBUBBLEBEFORE.png]]
[[File:SpeachBubbleBefore.png|The result]]


Now with this method:
Now with this method:
Line 27: Line 28:
[imgView release];</source>
[imgView release];</source>


Now the result is:
Now the result is:<br/>
[[File:speach_bubble_after.png|The result]]


[[Category:IOS]]
[[Category:IOS]]

Revision as of 10:33, 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