Note that there are some explanatory texts on larger screens.

plurals
  1. POresizableImage for UIImageView
    primarykey
    data
    text
    <p>I am working for IOS 5.0 as minTarget</p> <p>I have a UIImageView to which i want to assign a resizable image, so that image don't get stretch from corners.</p> <p>i have tried setting content mode of UIImageView to UIViewContentModeScaleToFill. But the image appears as tiled.</p> <p>here's the code </p> <pre><code>UIImage *bgImage = [[UIImage imageNamed:@"ImgViewBg"] resizableImageWithCapInsets:UIEdgeInsetsMake(2, 2, 2, 2)]; imgView.contentMode = UIViewContentModeScaleToFill; imgView.image = bgImage; </code></pre> <p>I am looking for the same effect as we have with 9patch images in android</p> <p>here's the image i am trying on <img src="https://i.stack.imgur.com/IcpYJ.png" alt="ImgViewBg"></p> <p>I just gave an another look at the documentation of resizeableImageWithCapInsets. It says it tiles the the area which is not under cap. I think that what causing the tiled pattern. Is there any workaround to this so that i can have 9Patch style image??</p> <h1>EDIT</h1> <p>According to Apple Docs<br> upto IOS 5.0 following works for my req.<br> [[UIImage imageNamed:@"textViewBg"] stretchableImageWithLeftCapWidth:6 topCapHeight:6]; (as mentioned by Dipen Panchasara) </p> <p>IOS6.0 and later following works for my req.<br> - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets resizingMode:(UIImageResizingMode)resizingMode </p> <p>IOS 5.0 and later (which i required)<br> - (UIImage *)resizableImageWithCapInsets:(UIEdgeInsets)capInsets<br> above function does not work in my case, as it tiles the image not under cap.</p> <p>so for IOS 5.0 to IOS 6.0 i was not able to find anything which solves my requirement.</p> <p>For now i moving to use Dipen Panchasara solution, i hope it stays stable</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload