簡體   English   中英

自定義動畫后的UIButton操作

[英]UIButton action after custom animation

我想使用UIButton連接自定義動畫,因此我決定使用超類UIButton創建自己的類。 然后我像這樣重載了touchesBegan方法

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[UIView animateKeyframesWithDuration:0.5
                               delay:0
                             options: 0
                          animations:^{

                              [UIView addKeyframeWithRelativeStartTime:0
                                                      relativeDuration:0.5
                                                            animations:^{
                                                                self.transform = CGAffineTransformScale(self.transform, 0.7, 0.7);
                                                            }];

                              [UIView addKeyframeWithRelativeStartTime:0.5
                                                      relativeDuration:0.5
                                                            animations:^{
                                                                self.transform = CGAffineTransformIdentity;
                                                            }];

                          }
                          completion:^(BOOL finished) {
                              [super touchesBegan:touches withEvent:event];
                          }];}

動畫效果很好,但是之后什么也沒發生。 看來調用super方法在完成處理程序中不起作用(不知道為什么)。 我的問題是:我應該如何更改以類似的方式延遲UIButton創建自己的類的動作?

編輯:我想創建自己的類,因為我在我的應用程序中有很多按鈕,我希望它們的行為相同。

通常將UIButton操作分配給在UIControlEventTouchUpInside上觸發,這應該在touchesEnded方法而不是touchesBegan中解決。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM