首页 > 在ios中.9.png怎么使用

在ios中.9.png怎么使用

在安卓中.9.png是做适配用的,现在我想利用他在ios定制一些控件。但是效果达不到
比如一个UIImageView中该怎么样使用他呢?求解???


我猜一下,可能你是android转过来的做ios的吧?
据我所知,一般ios没有android的9.png的说法,ios想要resizable image时要用到UIImage的resizableImageWithCapInsets方法(ios 5.0以后) ios 5.0以前可以使用stretchableImageWithLeftCapWidth: topCapHeight
希望能够帮到你

// >= ios 5.0 
UIImage *image = [[UIImage imageNamed:@"bg_box"] 
resizableImageWithCapInsets:UIEdgeInsetsMake(0,10,0,10)];

// < ios 5.0
[[UIImage imageNamed:@"bg_box"] stretchableImageWithLeftCapWidth:10 topCapHeight:10];

:


iOS一般用
[[UIImage imageNamed:@"1-pixel-image.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:0.0]

可参考:
https://www.evernote.com/shard/s4/sh/...

【热门文章】
【热门文章】