【问题标题】:how animate frames when set editing设置编辑时如何为帧设置动画
【发布时间】:2011-09-19 11:02:48
【问题描述】:

我想像 textLabel 一样平滑过渡 checkBox 和 noteButton。我尝试了这段代码但不起作用:

- (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];
}

【问题讨论】:

    标签: iphone ios cocoa-touch uitableview transition


    【解决方案1】:

    这应该可行。

    - (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];
    }
    

    【讨论】:

      【解决方案2】:

      试试看

      - (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);
        }
      }
      

      【讨论】:

        猜你喜欢
        • 2018-02-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多