首页 > 其他 > 详细

cell添加选中时的背景图片、显示图片和图片自适应框的大小

时间:2016-11-17 01:40:18      阅读:215      评论:0      收藏:0      [点我收藏+]

1.给cell添加选中时的背景图片

UIView *myview = [[UIView alloc] init];

myview.frame = CGRectMake(0, 0, 320, 47);

myview.backgroundColor =

[UIColor colorWithPatternImage:[UIImage

imageNamed:@"0006.png"]];

cell.selectedBackgroundView = myview;

2.显示图片

CGRect myImageRect = CGRectMake(0.0f, 0.0f, 320.0f,

109.0f);

UIImageView *myImage = [[UIImageView alloc]

initWithFrame:myImageRect];

[myImage setImage:[UIImage

imageNamed:@"myImage.png"]];

myImage.opaque =YES;

[self.view addSubview:myImage];

3.图片自适应框的大小

NSString*imagePath = [[NSBundle mainBundle]

pathForResource:@"XcodeCrash"ofType:@"png"];

UIImage *image = [[UIImage

alloc]initWithContentsOfFile:imagePath];

UIImage *newImage= [image transformWidth:80.f height:

240.f];

UIImageView *imageView = [[UIImageView

alloc]initWithImage:newImage];

[self.view addSubview:imageView];

cell添加选中时的背景图片、显示图片和图片自适应框的大小

原文:http://www.cnblogs.com/CJH5209/p/6072132.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!