【问题标题】:Value of type 'CGRect' has no member 'makeIntegralInPlace'“CGRect”类型的值没有成员“makeIntegralInPlace”
【发布时间】:2023-03-31 07:54:01
【问题描述】:

我在 Swift 3 之前有这个工作(frame 是 CGRect):

extraLightBlurView.frame.makeIntegralInPlace()

但它在 Swift 3 中返回错误 Value of type 'CGRect' has no member 'makeIntegralInPlace'。如何解决这个问题?

【问题讨论】:

    标签: swift swift3 cgrect


    【解决方案1】:

    它在 Swift 3 中不可用。请改用 integral 属性:

    extraLightBlurView.frame = extraLightBlurView.frame.integral
    

    Documentation

    【讨论】:

    • 不只是重命名,它返回一个值而不是改变给定的矩形。 (CGRect 在 Swift 3 中根本没有变异成员。)
    • 重命名了吗?但它也出现在 swift 2.0 @jrturton 中。正如 Martin R 所说,它在 swift 3.0 中被删除(makeIntegralInPlace)。
    • extraLightBlurView.frame.integral 返回一个 CGRect。但是我之前的方法makeIntegralInPlace 正在执行一些任务。我想用这个新的返回值做什么?我是否需要在 Swift 3 中调用 makeIntegralInPlace 或者有其他方式来执行 makeIntegralInPlace 曾经做的事情。
    • 更新了答案。我没有意识到 makeIntegralInPlace 实际上会反馈到视图的框架,我很高兴他们改变了这一点。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 2016-03-11
    • 1970-01-01
    • 1970-01-01
    • 2021-06-17
    相关资源
    最近更新 更多