2016-08-30 41 views
0

有沒有辦法讓我的UITableView模糊它的內容,除了一個單元格?Peek n'Pop動畫上的自定義力量觸摸手勢

我正在構建一個自定義的力量觸摸手勢識別器,並且當力值足夠高時它將顯示一個視圖。問題是,我想在力量不足以觸發它時顯示一些反饋,所以我想以某種方式從Peek n Pop中調用相同的動畫。那可能嗎?

編輯: 我想模擬這樣的: https://developer.apple.com/library/prerelease/content/documentation/UserExperience/Conceptual/Adopting3DTouchOniPhone/Art/preview_available_2_2x.png

回答

1

從我可以告訴,你是想用UIViewControllerPreviewingDelegate,這將需要你實現這個方法:

斯威夫特

func previewingContext(_ previewingContext: UIViewControllerPreviewing, 
     viewControllerForLocation location: CGPoint) -> UIViewController? 

Objective-C

- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext 
       viewControllerForLocation:(CGPoint)location 

這將使你返回UIViewController是被當推的力變得足夠大,以提交返回UIViewController。在previewingContext設置sourceRect屬性將讓你做你想要什麼:

previewingContext.sourceRect = someRect 

您需要將sourceRect所需UITableViewCell的框架。這將使整個視圖成爲'重點',而其他一切都變得模糊不清。

來源:

  1. UIViewControllerPreviewingDelegate
  2. UIKit Peek and Pop
  3. Objective-C tutorial for the effect
+0

是的,我知道。已經實施。但我不想使用Apple的Peek n Pop,因爲我在「Peek」中沒有任何內容。我想要使​​用Peek動畫,但不必呈現預覽視圖控制器瞭解? –