gpt4 book ai didi

ios - 使用 UIDynamicAnimator 后图像模糊

转载 作者:行者123 更新时间:2023-11-29 02:55:05 25 4
gpt4 key购买 nike

我使用 UIDynamicsAnimator 取得了良好的效果,只是动画完成后,插入和弹起的图像变得模糊。请帮助我。

@property (nonatomic,weak) IBOutlet UIImageView *someImage;

self.animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];

self.gravity = [[UIGravityBehavior alloc] initWithItems:@[self.someImage]];
CGVector gravityDirection = {-1.0, 0.5};
[self.gravity setGravityDirection:gravityDirection];

self.collision = [[UICollisionBehavior alloc] initWithItems:@[self.someImage]];
self.collision.translatesReferenceBoundsIntoBoundary = YES;

self.itemBehaviour = [[UIDynamicItemBehavior alloc] initWithItems:@[self.someImage]];
self.itemBehaviour.elasticity = 0.5;

[self.animator removeAllBehaviors]; // to avoid problems from the last behaviour animation

[self.collision addBoundaryWithIdentifier:@"barrier"
fromPoint:CGPointMake(444,0)
toPoint:CGPointMake(444,768)];

self.pushBehavior = [[UIPushBehavior alloc] initWithItems:@[self.someImage] mode:UIPushBehaviorModeInstantaneous];
self.pushBehavior.magnitude = 1.0f;
self.pushBehavior.angle = 0.0f;
[self.animator addBehavior:self.pushBehavior];

self.pushBehavior.pushDirection = CGVectorMake(1.0f, 0.0f)
self.pushBehavior.active = YES;

[self.animator addBehavior:self.itemBehaviour];
[self.animator addBehavior:self.collision];
[self.animator addBehavior:self.gravity];

最佳答案

我认为你的问题是动画完成时图像没有位于精确的点上。我建议您添加一个委托(delegate),当动画暂停时,您将图像的 x 和 y 舍入为最接近的整数。

关于ios - 使用 UIDynamicAnimator 后图像模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24002748/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com