【问题标题】:Peek n' Pop animation on custom force touch gesture自定义强制触摸手势上的 Peek n' Pop 动画
【发布时间】:2016-08-30 20:13:16
【问题描述】:

有没有办法让我的 UITableView 模糊它的内容,除了一个单元格?

我正在构建一个自定义强制触摸手势识别器,当强制值足够高时它会显示一个视图。问题是,当力不足以触发它时,我想显示一些反馈,所以我想以某种方式从 Peek n Pop 中调用相同的动画。这可能吗?

编辑: 我想模拟这个: https://developer.apple.com/library/prerelease/content/documentation/UserExperience/Conceptual/Adopting3DTouchOniPhone/Art/preview_available_2_2x.png

【问题讨论】:

    标签: ios objective-c cocoa-touch uiviewanimation


    【解决方案1】:

    据我所知,您想使用UIViewControllerPreviewingDelegate,这需要您实现此方法:

    斯威夫特

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

    Objective-C

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

    这些将允许您返回一个UIViewController,当力变得足以提交返回的UIViewController 时,该UIViewController 会被推送。在previewingContext 上设置sourceRect 属性将允许你做你想做的事:

    previewingContext.sourceRect = someRect
    

    您可以将sourceRect 设置为所需的UITableViewCell 的框架。这将使sourceRect 成为整个视图的“焦点”,而其他一切都变得模糊。

    来源:

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

    【讨论】:

    • 是的,我知道。已经实施。但我不想使用 Apple 的 Peek n Pop,因为我没有任何东西可以在“Peek”中呈现。我想使用 Peek 动画但无需呈现预览视图控制器了解吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多