http://childhoodgamedev.qiniudn.com/xincheng_testGif.gif
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(250, 250, 200, 100)];
label.text = @"Hello world!";
label.textColor = [UIColor blackColor];
label.textAlignment = NSTextAlignmentLeft;
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont systemFontOfSize:25];
[self.view addSubview:label];
CGAffineTransform transform = CGAffineTransformIdentity;
label.transform = CGAffineTransformScale(transform, 2, 2);
[UIView animateWithDuration:4.0 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
label.transform = CGAffineTransformTranslate(label.transform, -100, 0);
} completion:^(BOOL finished) {
if (finished) {
NSLog(@"label %f %f %f %f", label.frame.origin.x, label.frame.origin.y, label.frame.size.width, label.frame.size.height);
[UIView animateWithDuration:3.0 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
NSLog(@"label %f %f %f %f", label.frame.origin.x, label.frame.origin.y, label.frame.size.width, label.frame.size.height);
label.transform = CGAffineTransformTranslate(label.transform, 100, 0);
} completion:NULL];
}
}];
UILabel
个实例名为label
,它按CGAffineTransformScale
缩放为2比率。然后它从右向左移动,当动画完成时,它从左向右移动。
但奇怪的是:它看起来不是同一个位置,这是动画的终点(从右到左),动画的起点(从左到右)。但NSLog告诉我,他们处于相同的位置。
http://childhoodgamedev.qiniudn.com/xincheng_QQ20150306-1.png
当我评论州label.transform = CGAffineTransformScale(transform, 2, 2);
时,一切都很好。当标签改变方向移动时,右 - >左动画的结束位置只是左 - 右动画的起始位置。
所以我认为问题是由CGAffineTransformScale
引起的。有什么想法吗?