UIImage stretches only part

So let's say I have this sprite:

mbm bcb mbm 

where each letter is a part. (m: margin; b: border, c: center)

and I want a class capable of repeating b and c until it has to complete the view, so I get something like this:

 mbbbbbbbbbbbbbm bcccccccccccccb bcccccccccccccb bcccccccccccccb mbbbbbbbbbbbbbm 

Is there something that can do this? If it does not exist, any ideas on how to implement it?

+4
source share
2 answers

Could you achieve this with this method?

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

(see Apple UIImage Class Reference )

+8
source

We can stretch the image using the code below: - Here we need m..m to be the same size, so we stretch the middle part

 UIImage *image = [UIImage imageNamed:@"img_loginButton.png"]; UIEdgeInsets edgeInsets; edgeInsets.left = 3.0f; //Assume it is the pixel for starting 'm' edgeInsets.top = 0.0f; edgeInsets.right = 3.0f; //Assume it is the pixel for Ending 'm' edgeInsets.bottom = 0.0f; image = [image resizableImageWithCapInsets:edgeInsets]; //Use this image as your controls image 
+2
source

All Articles