ios - 使用 UIDynamicAnimator 后图像模糊

标签 ios cocoa-touch uidynamicanimator

我使用 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/

相关文章:

ios - 在移动设备中使用正则表达式模式的 html5 输入类型编号

ios - 如何让 UIImageView 填充 UITableViewCell?

objective-c - 在这种情况下是否需要 dispatch_async(dispatch_get_main_queue(), ...) ?

ios - 具有帧大小的数组

ios - 为什么导航 View Controller 返回零 View Controller ?

ios - 如何在 ios 中搜索输入字符串中的所有单词?

ios - 关键帧动画关键时间

IOS UIDynamicAnimator masksToBounds 不会将碰撞作为边界

swift - UIGravityBehavior 在移动项目后不起作用

ios - 使用 ReferenceView 延迟实例化 UIDynamicAnimator - Swift