簡體   English   中英

使用UIDynamicAnimator時,CGAffineTransformScale不會發送它的比例

[英]CGAffineTransformScale does not send it's scale when using UIDynamicAnimator

我只是想了解使用updateItemUsingCurrentState的方法以及如何向動畫師發送縮放的UIView或UIImageView,這樣我就可以在viewDidLoad上有一個大盒子和小盒子進行物理測試。 我想學習如何傳遞這個信息,以便我可以在其他事件中稍后動態更改大小。

我看到updateItemUsingCurrentState是來自下面的鏈接和apple docs的答案,但沒有一個難以讓比例工作的例子。 UIDynamicAnimator用於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;


}

我在這里回答我自己的Q,因為互聯網似乎似乎沒有問,所以我在某處錯過了一些文檔。

你不能使用Affines他們只是不喜歡動畫師。 所以我發現你從動態中刪除視圖並更改“邊界”或“框架”然后將視圖添加回動畫師。

[_gravity removeItem:_wrapperWolfBox];
  CGRect frameZr = _wrapperWolfBox.bounds;
    frameZr.size.height += 60.0f;
    frameZr.size.width += 60.0f;
    _wrapperWolfBox.bounds = frameZr;
[_gravity addItem:_wrapperWolfBox];

這讓我想到了下一個有趣的新問題和發現。 規模是即時的。 其中你可能想要但我沒有。 生病了,請問在一篇新帖子中。

請享用!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM