【发布时间】:2011-07-28 10:06:13
【问题描述】:
我有一张图片,我用它来构筑一条推文。它由两个圆形矩形组成,左上角有一个推特图标。重要的部分是它是可重复的,因为您可以垂直复制中间部分的任何部分,它会是相同的,只是更长。这是我创建的图像:
我的问题是,在代码中,我如何根据 UITextView 中有多少行来扩展(或缩小)它?像这样获得大小的东西:
float requiredHeight = lines * 14;
我知道这是可能的,因为苹果用他们的 SMS 应用程序做到了 :)
更新:这是执行此操作的完整代码:
UIImage *loadImage = [UIImage imageNamed:@"TwitPost.png"];
float w2 = loadImage.size.width/2;
float h2 = loadImage.size.height/2;
// I have now reduced the image size so the height must be offset a little (otherwise it stretches the bird!):
loadImage = [loadImage stretchableImageWithLeftCapWidth:w2 topCapHeight:h2+15];
imageView.image = loadImage;
感谢您的两个回答。
【问题讨论】:
标签: iphone objective-c ios uiimageview uiimage