第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用UIView animateWithDuration進(jìn)行動(dòng)畫(huà)處理時(shí),無(wú)法觸摸UIButton

使用UIView animateWithDuration進(jìn)行動(dòng)畫(huà)處理時(shí),無(wú)法觸摸UIButton

RISEBY 2019-08-19 11:05:08
使用UIView animateWithDuration進(jìn)行動(dòng)畫(huà)處理時(shí),無(wú)法觸摸UIButton我有以下代碼:[UIView animateWithDuration:0.3                       delay:0.0                     options:UIViewAnimationCurveEaseOut | UIViewAnimationOptionAllowUserInteraction                  animations:^{                      CGRect r = [btn frame];                      r.origin.y -= 40;                      [btn setFrame: r];                  }                  completion:^(BOOL done){                      if(done){                          [UIView animateWithDuration:0.3                                                delay:1                                              options:UIViewAnimationOptionCurveEaseIn | UIViewAnimationOptionAllowUserInteraction                                           animations:^{                                               CGRect r = [btn frame];                                               r.origin.y += 40;                                               [btn setFrame: r];                                           }                                           completion:^(BOOL done){if(done) zombiePopping = 0; }];                      }                  }];問(wèn)題是,即使我正在使用UIViewAnimationOptionAllowInteraction,按鈕也不會(huì)在動(dòng)畫(huà)時(shí)響應(yīng)觸摸,這對(duì)我來(lái)說(shuō)有點(diǎn)奇怪。也許最好用Core Animation來(lái)完成這項(xiàng)工作?如果是的話,我該怎么做呢?問(wèn)題是,即使我正在使用UIViewAnimationOptionAllowInteraction,按鈕也不會(huì)在動(dòng)畫(huà)時(shí)響應(yīng)觸摸,這對(duì)我來(lái)說(shuō)有點(diǎn)奇怪。也許最好用Core Animation來(lái)完成這項(xiàng)工作?如果是的話,我該怎么做呢?
查看完整描述

3 回答

?
哆啦的時(shí)光機(jī)

TA貢獻(xiàn)1779條經(jīng)驗(yàn) 獲得超6個(gè)贊

按鈕的可觸摸部分在動(dòng)畫(huà)時(shí)不會(huì)與按鈕的可見(jiàn)幀重合。

在內(nèi)部,按鈕的框架將設(shè)置為動(dòng)畫(huà)的最終值。你會(huì)發(fā)現(xiàn)你可以點(diǎn)擊這個(gè)區(qū)域,它會(huì)起作用。

要點(diǎn)擊一個(gè)移動(dòng)按鈕,你需要對(duì)按鈕的.layer.presentationLayer屬性進(jìn)行命中測(cè)試(需要導(dǎo)入QuartzCore框架才能執(zhí)行此操作)。這通常在視圖控制器中的觸摸處理方法中完成。

如果您需要更多,我很樂(lè)意擴(kuò)展這個(gè)答案。

以下是如何通過(guò)命中測(cè)試表示層來(lái)響應(yīng)觸摸事件。此代碼位于管理按鈕的視圖控制器子類中。當(dāng)我這樣做時(shí),我對(duì)初始觸摸而不是觸摸結(jié)束感興趣(這通常是當(dāng)水龍頭會(huì)注冊(cè)時(shí)),但原理是相同的。

記得導(dǎo)入QuartzCore框架并將其添加到項(xiàng)目中。

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch = [touches anyObject];
    CGPoint touchLocation = [touch locationInView:self.view];
    for (UIButton *button in self.buttonsOutletCollection)
    {
        if ([button.layer.presentationLayer hitTest:touchLocation])
        {
            // This button was hit whilst moving - do something with it here
            break;
        }
    }}


查看完整回答
反對(duì) 回復(fù) 2019-08-19
?
白衣染霜花

TA貢獻(xiàn)1796條經(jīng)驗(yàn) 獲得超10個(gè)贊

在我的情況下,我設(shè)置superView.alpha = 0,它停止按鈕的交互,雖然我設(shè)置UIViewAnimationOptionAllowUserInteraction。

解?容易,只需減少alpha 到0.1而不是0

[UIView animateWithDuration:durationTime delay:0 options:UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionOverrideInheritedOptions | UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse animations: ^{
            superView.alpha = 0.1; // 0.0 will make the button unavailable to touch
        } completion:nil];


查看完整回答
反對(duì) 回復(fù) 2019-08-19
?
慕標(biāo)5832272

TA貢獻(xiàn)1966條經(jīng)驗(yàn) 獲得超4個(gè)贊

選項(xiàng)的順序是重要的,您必須先放置UIViewAnimationOptionAllowUserInteraction,然后添加其他選項(xiàng)。

在Swift 3中使用: .allowUserInteraction


查看完整回答
反對(duì) 回復(fù) 2019-08-19
  • 3 回答
  • 0 關(guān)注
  • 1605 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)