stretchableImageWithLeftCapWidth 的使用
来源:互联网 发布:成都网站制作龙兵网络 编辑:程序博客网 时间:2024/06/08 11:52
UIImage stretchableImageWithLeftCapWidth的使用一直比较迷惑,不明白,并且在开始的使用中总是失败,结合着网上的资料,经过多次实验,终于明白他的用处了, leftCapWidth ,是左侧需要保留的像素数,topCapHeight是顶部需要保留的像素数,然后中间的1像素用于中间的平铺,达到最后所需要的尺寸。效果相当于只能保持一边固定,拉伸另一边。 并且以前使用image后,没有设置到指定的大小,所以没有看到效果。
示例代码:
UIImage* image = [UIImage imageNamed:@"listbg2"]; image = [image stretchableImageWithLeftCapWidth:floorf(image.size.width/2) topCapHeight:60]; UIImageView* backgrdView = [[UIImageView alloc] initWithFrame:rect]; backgrdView.center = CGPointMake(160.0, 80.0); backgrdView.contentMode = UIViewContentModeScaleToFill; backgrdView.image = image; rect = backgrdView.frame; [cell.contentView addSubview:backgrdView];
上面,1. backgrdView的起始坐标是相当于父视图,坐标切换容易出错,需要注意坐标的范围,是相对于哪个视图的坐标值。
2. 将一个图片视图作为背景图,并且不同于cell大小,直接设置 backgrounView,backgroundColor,都是有问题的,不如直接添加到contentView 中
只是自己总结,不一定准确,有待后续确认修正
- stretchableImageWithLeftCapWidth 的使用
- stretchableImageWithLeftCapWidth的使用
- stretchableImageWithLeftCapWidth 的使用
- stretchableImageWithLeftCapWidth 的使用
- UIImage的 stretchableImageWithLeftCapWidth 方法的使用
- UIButton 背景图片延长 笔记 stretchableImageWithLeftCapWidth的使用
- 图片拉伸处理:stretchableImageWithLeftCapWidth方法的使用
- stretchableImageWithLeftCapWidth:topCapHeight:使用
- UIImage部分拉伸——stretchableImageWithLeftCapWidth的使用
- UIImage部分拉伸——stretchableImageWithLeftCapWidth的使用
- iOS UIImage部分拉伸——stretchableImageWithLeftCapWidth的使用
- UIImage部分拉伸——stretchableImageWithLeftCapWidth的使用
- stretchableImageWithLeftCapWidth
- stretchableImageWithLeftCapWidth
- stretchableImageWithLeftCapWidth
- stretchableImageWithLeftCapWidth
- stretchableImageWithLeftCapWidth
- stretchableImageWithLeftCapWidth
- POJ 1129 Channel Allocation 着色问题 dfs
- 当前session生成redo,undo大小,统计信息,以及表的大小
- hdu4350 Card-----多校联合六
- android消息推送
- Oracle APEX Classical Report的列根据条件判断显示为Link
- stretchableImageWithLeftCapWidth 的使用
- UVA 127 - "Accordian" Patience---用STL做的(TLE超时)
- ubuntu下tftp文件,Retry count exceeded; starting again问题
- secure crt 6.6.3 设置
- 教你玩转11gR2 GNS(Grid Naming Service)
- 原型模式
- 屏幕的FMARK--最后一段是出现切屏的本质
- Poco::BasicEvent
- hdu_4355 Party All the Time(简单数学题)