【问题标题】:Expression type '@lvalue UIImage?' is ambiguous without more context表达式类型'@lvalue UIImage?'没有更多上下文是模棱两可的
【发布时间】:2018-10-16 10:19:42
【问题描述】:

我得到“表达式类型'@lvalue UIImage?'使用 swift 4 在 IOS 中设置图像的色调颜色时出现“在没有更多上下文的情况下模棱两可”的错误。

cell.icon.image = cell.icon.image?.renderingMode(.alwaysTemplate)

是不是我做错了什么?

【问题讨论】:

  • 你试过这样吗? cell.icon.image = cell.icon.image?.withRenderingMode(.alwaysTemplate)
  • @AhmetSinaUstem 谢谢这是问题

标签: ios swift


【解决方案1】:

UIImage.renderingMode 是一个属性,所以你不能像函数一样调用它。您只需访问单元格的属性并为其分配一个新值。

cell.icon.image?.renderingMode = .alwaysTemplate

如果你真的想修改image属性本身而不是仅仅改变它的renderMode,你需要调用withRenderingMode

cell.icon.image = cell.icon.image?.withRenderingMode(.alwaysTemplate)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-15
    • 2016-12-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多