詳解IOS UITableViewCell 的 imageView大小更改
實例代碼:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil){
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
cell.textLabel.text = [self.arrStr objectAtIndex:indexPath.row];
UIImage *img = [UIImage imageNamed:[self.arrImg objectAtIndex:indexPath.row]];
cell.imageView.image = img;
//iOS UITableViewCell 的 imageView大小更改
CGSize itemSize = CGSizeMake(img.size.width *2/3, img.size.height *2/3);
UIGraphicsBeginImageContext(itemSize);
CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
[cell.imageView.image drawInRect:imageRect];
cell.imageView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
}
return cell;
}
以上就是關于IOS UITableViewCell 的 imageView大小更改的實例,本站還有很多關于IOS 開發的文章,歡迎大家搜索參閱,
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。