我只是想了解使用updateItemUsingCurrentState的方法,以及如何将缩放的UIView或UIImageView发送给动画师,这样我就可以在viewDidLoad上有一个大盒子和一个小盒子来进行物理测试。我想学习如何传递这个信息,这样我就可以在其他事件中动态地更改大小。
我看到了updateItemUsingCurrentState是从下面的链接和苹果文档中得到的答案,但是没有什么难的例子来获得一个刻度。UIDynamicAnimator for views with CGAffineTransform
我肯定会发现,我需要改变界限或其他什么,但就目前而言,我只是想通过这个障碍。
@property (strong, nonatomic) IBOutlet UIView *CatBox;
@property (strong, nonatomic) IBOutlet UIImageView *catFishBox;
@property (nonatomic) UIDynamicAnimator* animator;
@property (strong, nonatomic) IBOutlet UIView *wrapperWolfBox;
@end
@implementation CatFishViewController
UIDynamicAnimator* _animator;
UIGravityBehavior* _gravity;
UICollisionBehavior* _collision;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
_animator = [[UIDynamicAnimator alloc] initWithReferenceView:self.view];
_gravity = [[UIGravityBehavior alloc] initWithItems:@[_wrapperWolfBox]];
[_animator addBehavior:_gravity];
_collision = [[UICollisionBehavior alloc]
initWithItems:@[_wrapperWolfBox]];
_collision.translatesReferenceBoundsIntoBoundary = YES;
[_animator addBehavior:_collision];
//
//
CGAffineTransform maybeGetTransform = CGAffineTransformScale(_wrapperWolfBox.transform, 2.2, 2.2);
_wrapperWolfBox.transform = maybeGetTransform;
[_animator updateItemUsingCurrentState:self.wrapperWolfBox];
// _animator.updateItemUsingCurrentState:self.catFishBox;
}发布于 2013-11-28 09:40:00
我在这里回答我自己的问题,因为互联网似乎没有问,所以我错过了一些医生。
你不能用仿射,他们只是对动画师不友好。因此,我发现您从动态中移除视图,并更改“界限”或“框架”,然后将视图添加到动画中。
[_gravity removeItem:_wrapperWolfBox];
CGRect frameZr = _wrapperWolfBox.bounds;
frameZr.size.height += 60.0f;
frameZr.size.width += 60.0f;
_wrapperWolfBox.bounds = frameZr;
[_gravity addItem:_wrapperWolfBox];这让我想到了我下一个有趣的问题和发现。规模是即时的。你可能想要,但我不想。所以我会在新的岗位上问这个问题。
享受吧!
https://stackoverflow.com/questions/19869111
复制相似问题