ios - UIImageView 设置为 ASpectFill 时出现内容模式问题

标签 ios xcode uitableview uiimageview uiimage

我需要在单元格中加载图像,我的图像上有一个白色边框。我从链接调用图像,它看起来像这样。

enter image description here

但是我的图片看起来像

enter image description here

我的图像左侧和右侧出现白色边框。这是我的图像代码

    UIImageView *item=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 115, 130)];

    NSString *imgstring=[NSString stringWithFormat: @"%@",[[mutarray objectAtIndex:indexPath.row ] valueForKey:@"imgurl"]];

    NSURL *imgurl=[NSURL URLWithString:imgstring];

    UIImage *image=[UIImage imageWithData:[NSData dataWithContentsOfURL:imgurl]];


    [item setBackgroundColor:[UIColor clearColor]];
    item.contentMode=UIViewContentModeScaleToFill;
    [item setImage:image];
    [cell.contentView addSubview:item];

请指导...

最佳答案

那些白色边框在您在问题中发布的图片中……这就是它们也出现在 iOS 中的原因。在照片编辑器中打开该图片,您会看到。

关于ios - UIImageView 设置为 ASpectFill 时出现内容模式问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11633405/

相关文章:

ios - 授予地址簿请求后获取用户自己的电话号码信息

iOS7 itms-services 方案不起作用?

swift - 如何向 UITableView 单元格添加视差效果

ios - 自动调整 Tableview 单元格到单元格内容(SWIFT)

iphone - JSONKit 在从 iPhone 中的 Web 服务解码 JSON 对象时更改浮点值

objective-c - 更改 View 在 viewDidLoad 中有效,但在单击 IBAction 按钮时无效

iphone - 我们如何创建一个干净的 iOS 项目(没有 Interface Builder 文件)?

xcode - 带有标识符X的应用程序ID不可用

Swift:在 JSON 数据的 TableView 返回中同步数据的呈现

iphone - 在 ViewDidLoad 上将 plist 加载到 NSArray 中