//当用到UITableView 时。往往背景图片要根据内容的大小而定。但如果不用stretchableImageWithLeftCapWidth。刚图片拉出来会很难看。 //图片自动适应内容大小 UIImage *chatImage=[UIImage imageNamed:@"bubble.png"]; chatImage = [chatImage stretchableImageWithLeftCapWidth:22 topCapHeight:14]; NSLog(@"tbvContentSizeForLines:%f",tbvContentSizeForLines.width); cell.resultChatImageView.frame = CGRectMake(10, 44, tbvContentSizeForLines.width+25, cell.resultPersonTbvContent.numberOfLines*26+8); cell.resultChatImageView.image = chatImage;

本文介绍如何在使用UITableView时,实现背景图片自动根据内容大小进行调整,避免图片拉伸变形的问题。通过使用stretchableImageWithLeftCapWidth和tbvContentSizeForLines属性,可以确保图片始终与内容相匹配,提升用户体验。
1415

被折叠的 条评论
为什么被折叠?



