我正在使用图像来显示UITableViewCell的整个内容,并使用backgroundView属性进行设置。UITableViewCell backgroundView图像调整大小?
我的问题是,它总是适合细胞的比例。有没有办法在这种情况下禁用缩放,所以我只能提供480像素的版本,它只是在方向是纵向时被裁剪?
我做这样的:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
UIImageView *bgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"menu.0%d.large.png", indexPath.row+1]]];
UIImageView *selectedBgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"menu.0%d.large.selected.png", indexPath.row+1]]];
cell.backgroundView = bgView;
cell.selectedBackgroundView = selectedBgView;
[bgView release];
[selectedBgView release];
return cell;
}
我尝试使用图像的两个版本取向时改变它们之间进行切换。这个工作到目前为止,但它的缺点是你总是看到处理动画时的缩放比例。
感谢您的帮助
阿恩
感谢您的回答。我太迟了,因为我回来时已经找到了詹姆斯的解决方案。但是,无论如何感谢您的帮助! – arnekolja 2010-10-16 16:06:09
谢谢!我将'UIViewContentModeTopLeft'与'clipToBounds = YES'组合使用,以便为我的项目工作。 – primehalo 2015-12-21 00:50:15