stretchableImageWithLeftCapWidth 自动适应UITableView

 
//当用到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;



原文地址:https://www.cnblogs.com/qingjoin/p/2679461.html