嗨,我有一个 UIView,我在它的initWithFrame:
方法中添加了一个 UIButton,如下所示:
UIButton * dropB = [UIButton buttonWithType:UIButtonTypeRoundedRect];
dropB.frame = CGRectMake(190, 22, 52, 22);
dropB.backgroundColor = [UIColor clearColor];
dropB.titleLabel.font = [UIFont fontWithName:@"Helvetica-Bold" size:11];
[dropB setTitle:@"DROP" forState:UIControlStateNormal];
[dropB addTarget:viewController
action:@selector(dropSelectedObject)
forControlEvents:UIControlEventTouchUpInside];
[self addSubview:dropB];
然后,当我尝试使用这样的调整大小为视图设置动画时:
[UIView beginAnimations:@"MoveIt" context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.dropButton.center = CGPointMake(self.dropButton.center.x + 80, self.dropButton.center.y -10);
self.frame = CGRectMake(0, 0, WIDTH, HEIGHT);
self.center = CGPointMake(CENTER_X, CENTER_Y);
[UIView commitAnimations];
该按钮只会被翻译到一个新位置,即前一个位置(我猜原始坐标是相对于视图的)。我怎样才能把它翻译成我指定的点?