Peek和Pop 3D Touch - 非矩形预览文本演示

时间:2016-06-23 01:21:19

标签: ios calayer 3dtouch

在指示暗示和弹出的提示期间(当所有其他开始模糊时,被按下的视图保持清晰的那一刻),我希望保持清晰的区域是非矩形的...梯形,是精确。如何做到这一点?

在实现3D Touch时,我们都知道我们在方法中设置了previewingContext的sourceRect属性

- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)previewingContext viewControllerForLocation:(CGPoint)location
我看起来像这样:

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

    if (CGRectContainsPoint(self.particularView.frame, location)) {

        previewingContext.sourceRect = self.particularView.frame;

        MyCustomViewController *customVC = [[MyCustomViewController customInit];
        customVC.modalPresentationStyle = UIModalPresentationOverFullScreen;
        customVC.preferredContentSize = self.view.frame.size;

        return customVC;
    }

    return nil;
}

一切都有效,完全像想象的那样。但我不希望previewingContext.sourceRect的整个方块保持清晰!我想切掉一个角落,留下一个梯形锐利。有人有解决方案吗?

1 个答案:

答案 0 :(得分:0)

尝试

customVC.view.layer.cornerRadius = 10;