Vin*_*rel 0 iphone animation objective-c uiview ios
我有一个让我疯狂的问题,我想我没有足够的知识来找到这个问题的答案.
这里有一个完美的代码:
NSLog(@"%f, %f", imageList.center.x, imageList.center.y);
[imageList setCenter:CGPointMake(imageList.center.x, -imageList.center.y)];
NSLog(@"=> %f, %f", imageList.center.x, imageList.center.y);
Run Code Online (Sandbox Code Playgroud)
给我以下输出:
2016-01-08 11:48:42.585 User[4047:600095] 160.000000, 284.000000
2016-01-08 11:48:42.585 User[4047:600095] => 160.000000, -284.000000
Run Code Online (Sandbox Code Playgroud)
现在,如果我把这个setCenter放到UIView animationWithDuration中,就像这样
NSLog(@"%f, %f", imageList.center.x, imageList.center.y);
[UIView animateWithDuration:0.3 animations:^{
[imageList setCenter:CGPointMake(imageList.center.x, -imageList.center.y)];
} completion:^(BOOL finished) {*/
NSLog(@"=> %f, %f", imageList.center.x, imageList.center.y);
}];
Run Code Online (Sandbox Code Playgroud)
我得到这个输出:
2016-01-08 11:48:42.585 User[4047:600095] 160.000000, 284.000000
2016-01-08 11:48:42.585 User[4047:600095] => 160.000000, 284.000000
Run Code Online (Sandbox Code Playgroud)
你们有什么想法吗?我检查了约束和autoLayout,一切都很好.
试试这个 :
Objective-C的
[UIView animateWithDuration:0.3 delay:0.0 options:(UIViewAnimationOptionCurveLinear | UIViewAnimationOptionAllowUserInteraction) animations:^{
[imageList setCenter:CGPointMake(imageList.center.x, -imageList.center.y)];
} completion:nil];
Run Code Online (Sandbox Code Playgroud)
斯威夫特4
UIView.animate(withDuration: 0.3, delay: 0.0, options: .curveLinear, animations: {
imageList.center = CGPoint(x: imageList.center.x, y: -imageList.center.y)
}, completion: nil)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
690 次 |
| 最近记录: |