UIView动画改变了按钮的大小

Jos*_*osh 4 objective-c uibutton beginanimations ios

我开始尝试从应用程序商店重新创建购买按钮,这需要两个阶段的点击来购买东西.我动画按钮扩展.到目前为止,我有这个

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];

sender.autoresizesSubviews = NO;
sender.clipsToBounds = NO;
sender.frame = CGRectMake(63,326,200,37);

[UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

这只会导致按钮变大,根本没有动画效果.我做错了什么或有没有其他人实现这种类型的按钮行为?

编辑:

- (IBAction) buyButtonAction: (UIButton *) sender {

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationDelay:0.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];

sender.clipsToBounds = NO;

sender.frame = CGRectMake( CGRectGetMinX( sender.frame) - 30, CGRectGetMinY(sender.frame), 200, 37);
[sender setTitle:@"Touched Touched Touched" forState:UIControlStateNormal];


[UIView commitAnimations];
}
Run Code Online (Sandbox Code Playgroud)

Lrd*_*mir 7

您是否针对不支持Blocks的iOS?

我使用以下令人作呕的简单代码实现了"触摸按钮动画".

[UIView animateWithDuration:0.5 animations:^{
    self.navigationItem.rightBarButtonItem.title = @"Quoting...";
}];
Run Code Online (Sandbox Code Playgroud)

或者,如果你不能支持块,这个代码似乎也能用于触摸按钮的动画(它还包括如果你去那条路线注释掉的块):

-(IBAction) clicked:(UIButton*)sender{
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationDelay:0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    //[UIView animateWithDuration:2.5 animations:^{

    sender.autoresizesSubviews = NO;
    sender.clipsToBounds = NO;
    sender.frame = CGRectMake(63,326,200,37);

    //sender.frame = CGRectMake( CGRectGetMinX( self.theButton.frame) - 100, CGRectGetMinY(self.theButton.frame), 300, 40);
    //[sender setTitle:@"Touched Touched Touched" forState:UIControlStateNormal];
//}];
Run Code Online (Sandbox Code Playgroud)