I want to smooth transition checkBox and noteButton like textLabel. I tried this code but do not work:
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
if (self.editing == NO) {
self.checkBox.frame = CGRectMake(50, 0, 50, 50);
self.noteButton.frame = CGRect开发者_如何学PythonMake(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];
}
This should work.
- (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];
}
Try doing it in
- (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);
}
}
精彩评论