0
所以这是我的代码:的UIView动画不起作用
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
if (section == 0) {
if (!header) {
header = [[CustomBackground alloc] initWithFrame:CGRectMake(0, 0, 320, 30)];
float number = [self.total floatValue];
[self updateTotalLabel: &number];
}
return header;
}
return nil;
}
-(void)updateTotalLabel:(float *)amount
{
float currentValue = [self.total floatValue];
self.total = [NSNumber numberWithFloat:(currentValue + *amount)];
[header updateLabel:[NSString stringWithFormat:TOTAL, [total floatValue]]];
}
头updateLabel:
-(void)updateLabel:(NSString *)string
{
CGRect frame = self.frame;
frame.origin.y = -frame.size.height;
[UIView animateWithDuration:0.5
delay:0.1
options: UIViewAnimationCurveEaseOut
animations:^{
self.frame = frame;
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
self.frame = frame;
frame.origin.y = 0;
self.label.text = string;
[UIView animateWithDuration:0.5
delay:1.0
options: UIViewAnimationTransitionCurlDown
animations:^{
self.frame = frame;
}
completion:^(BOOL finished){
NSLog(@"Done!");
}];
[label setNeedsDisplay];
}
我打电话updateTotalLabel,每次当用户添加新记录的tableview时间。 我有一个动画问题,因为动画只能在第一次调用updateLabel后才起作用。
编辑
好了,我建议电影:YT
在输出,你可以看到当每个动画触发。
好的,我更新了;) – juantorena 2011-05-09 18:37:36