热图的UIDynamics

时间:2016-11-23 09:49:15

标签: ios dictionary uikit-dynamics uidynamicbehavior

对于客户,我需要认识到UIView应该与此类似:

To be screen

我的想法是使用UIDynamics和某种UIFieldBehaviour。所以我创建了一个容器视图containerView,添加了一堆UIView个。这些内部视图将添加到UIFieldBehavior.magneticField()(使用addItem)。

我还创建了UICollisionBehaviour添加相同的UIView s

下面是代码:

let  _animator = UIDynamicAnimator.init(referenceView: self.pointsReceivedMap)
let _magnet = UIFieldBehavior.magneticField()
let _collisions = UICollisionBehaviour()
_collisions.translatesReferenceBoundsIntoBoundary = true

for index in 1..<10 {
    let view = UIView();
    /*add some UI style to view */
    _collision.addItem(view)
    _magnet.addItem(view)
}

_animator.addBehaviour(_magnet)
_animator.addBehaviour(_collision)

这就是我得到的:

What I get

黄色视图是动画对象被引用时以referenceView传递的容器视图(self.pointsReceivedMap

0 个答案:

没有答案