这是我为子视图数组制作动画的方法:
+(void)moveToView:(NSMutableArray *)arrayToMove andYMovement:(float)movement andLabel:(UILabel *)piece toAdd:(BOOL)toggle andView:(UIView *)referenceView andtheory:(NSString *)theoryPackage
{
[UIView animateWithDuration:0.5 animations:^
{
for (UIView* pieceToMove in arrayToMove) {
CGRect projectileFrame = [[pieceToMove.layer presentationLayer] frame];
pieceToMove.frame = CGRectMake(projectileFrame.origin.x, projectileFrame.origin.y + movement, projectileFrame.size.width, projectileFrame.size.height);
NSLog(@"X-org: %f, Y-org: %f, Width: %f, Height: %f", projectileFrame.origin.x, projectileFrame.origin.y + movement, projectileFrame.size.width, projectileFrame.size.height);
piece.text = [NSString stringWithFormat:@""];
}
}
completion:^(BOOL finished) {
if (finished) {
if (toggle) {
piece.text = [NSString stringWithFormat:@"%@", theoryPackage];
}
}
}];
}
我只是使用日志来尝试跟踪我的观点。我的arrayToMove数组中有3个对象,2个按钮和一个标签。动画对于按钮工作正常,但由于某种原因,标签固执地不会向下移动按钮,这些按钮会混淆一切。任何想法?
以下是NSlog的结果:
2014-02-15 16:31:19.754 theoryDisplay[77092:70b] X-org: 80.000000, Y-org: 303.000000, Width: 160.000000, Height: 40.000000
2014-02-15 16:32:02.317 theoryDisplay[77092:70b] X-org: 80.000000, Y-org: 403.000000, Width: 897.000000, Height: 122.000000
2014-02-15 16:32:31.323 theoryDisplay[77092:70b] X-org: 80.000000, Y-org: 505.000000, Width: 160.000000, Height: 40.000000
不移动的视图是第二个。提前谢谢。