从AnyObject转换为UIEdgeInsets

时间:2016-07-17 16:20:47

标签: swift key-value-observing uiedgeinsets anyobject

我试图在scrollView' contentInset上使用KVO模式,我需要知道旧/新值。我知道UIEdgeInests是一个结构,因此无法存储在Dictionary中,但我会在更改中收到它。这是我的改变词典:

Optional(["old": UIEdgeInsets: {0, 0, 100, 0}, "new": UIEdgeInsets: {64, 0, 149, 0}, "kind": 1])

这就是我试图施展它的方式:

guard let oldValue = change?[NSKeyValueChangeOldKey] as? UIEdgeInsets,
        newValue = change?[NSKeyValueChangeNewKey] as? UIEdgeInsets
        else { return }

但总是失败。

如何将其投射到UIEdgeInsets?

0 个答案:

没有答案