具有Scale和Translate的iOS 8 CGAffineTransformConcat导致位置跳转

时间:2014-12-22 23:10:59

标签: ios objective-c core-animation uiviewanimation

我遇到了iOS 8中存在的CGAffineTransformConcat问题,但iOS 7中没有。使用带缩放和翻译的串联动画UIView会导致位置跳转。在iOS 7中运行相同的代码,可以获得所需的结果。是否存在导致此问题的变化?

这是我的示例代码......

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //add a view
    self.lilView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    self.lilView.backgroundColor = [UIColor greenColor];
    [self.view addSubview:self.lilView];

    //add a tap gesture
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(poop:)];
    [self.view addGestureRecognizer:tap];
}

-(void) poop:(UITapGestureRecognizer*) gesture {
    if (!self.pooped) {

    [UIView animateWithDuration:1 delay:0 options:0 animations:^{

        self.lilView.transform = CGAffineTransformConcat(CGAffineTransformMakeScale(2.0, 2.0), CGAffineTransformMakeTranslation(200, 300));

        self.pooped = YES;

    } completion:nil];

} else {

    [UIView animateWithDuration:1 delay:0 options:0 animations:^{

        self.lilView.transform = CGAffineTransformConcat(CGAffineTransformMakeScale(1.5, 1.5), CGAffineTransformMakeTranslation(100, 200));

        self.pooped = NO;

    } completion:nil];

}
}

感谢您的帮助!

0 个答案:

没有答案