2011-09-19 59 views
0

我想平滑過渡checkBox和noteButton像textLabel。我想這個代碼,但不工作:設置編輯時如何設置動畫幀

- (void)setEditing:(BOOL)editing animated:(BOOL)animated { 

    if (self.editing == NO) { 
     self.checkBox.frame = CGRectMake(50, 0, 50, 50); 
     self.noteButton.frame = CGRectMake(100, 0, 50, 50); 
     self.textLabel.frame = CGRectMake(95,0, 213, 48); 
    } else { 
     self.checkBox.frame = CGRectMake(10, 0, 50, 50); 
     self.noteButton.frame = CGRectMake(50, 0, 50, 50); 
     self.textLabel.frame = CGRectMake(95,0, 213, 48); 
    } 
    [super setEditing:editing animated:animated]; 
} 

回答

0

這應該工作。

- (void)setEditing:(BOOL)editing animated:(BOOL)animated { 
    [UIView beginAnimations:@"ResizeAnimation" context:NULL]; 
    [UIView setAnimationDuration:0.7f]; 
    if (self.editing == NO) { 
     self.checkBox.frame = CGRectMake(50, 0, 50, 50); 
     self.noteButton.frame = CGRectMake(100, 0, 50, 50); 
     self.textLabel.frame = CGRectMake(95,0, 213, 48); 
    } else { 
     self.checkBox.frame = CGRectMake(10, 0, 50, 50); 
     self.noteButton.frame = CGRectMake(50, 0, 50, 50); 
     self.textLabel.frame = CGRectMake(95,0, 213, 48); 
    } 
    [UIView commitAnimations]; 
    [super setEditing:editing animated:animated]; 
} 
0

嘗試做它

- (void) layoutSubviews { 
    if (self.editing == NO) { 
    self.checkBox.frame = CGRectMake(50, 0, 50, 50); 
    self.noteButton.frame = CGRectMake(100, 0, 50, 50); 
    self.textLabel.frame = CGRectMake(95,0, 213, 48); 
    } else { 
    self.checkBox.frame = CGRectMake(10, 0, 50, 50); 
    self.noteButton.frame = CGRectMake(50, 0, 50, 50); 
    self.textLabel.frame = CGRectMake(95,0, 213, 48); 
    } 
} 
+0

此代碼也工作,謝謝你 –