相关疑难解决方法(0)

裁剪CAShapeLayer检索外部路径

我试图用其他方法裁剪一个图层,但是,不是创建一个蒙版(B)并裁剪图层(A)获得一个形状为B的裁剪图层A,我希望得到一个形状为A的图层和一个'通过裁剪B层创建的洞'

*************               ***Layer A***
*  Layer A  *               *************
*   *****   *               ****    *****
*   * B *   *      ->       ****    ***** Layer A without shape B
*   *****   *               ****    *****
*           *               *************
*************               *************
Run Code Online (Sandbox Code Playgroud)

如何获得裁剪的A层?

core-graphics objective-c calayer uikit

7
推荐指数
1
解决办法
4665
查看次数

我如何(成功)将maskView设置为UIView?

我正在制作一个基于相机的应用程序,并希望在相机预览上制作一个磨砂覆盖图,从磨砂视图中切出一个圆角矩形.

我一直在努力用UIView的maskLayer实现这一点,在iOS 8中引入并且已经非常不成功.

这是我的代码目前的样子:

// Blur the preview
UIBlurEffect *effect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
UIView *blurView = [[UIVisualEffectView alloc] initWithEffect:effect];
blurView.translatesAutoresizingMaskIntoConstraints = NO;
[self.view insertSubview:blurView aboveSubview:imagePicker.view];

// Make blur view fill screen
{
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-0-[blurView]-0-|"
                                                                      options:0
                                                                      metrics:nil
                                                                        views:NSDictionaryOfVariableBindings(blurView)]];
    [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[blurView]-0-|"
                                                                      options:0
                                                                      metrics:nil
                                                                        views:NSDictionaryOfVariableBindings(blurView)]];
}

// Add a rounded of transparency to the blurView  **not working**
UIView *mask = [[UIView alloc] initWithFrame:CGRectMake(50.f, 50.f, 50.f, 50.f)];
mask.alpha = 1.0f;
mask.backgroundColor = [UIColor redColor];
[blurView setMaskView:mask]; // Remove this line, and everything …
Run Code Online (Sandbox Code Playgroud)

mask objective-c uiview ios ios8

5
推荐指数
1
解决办法
6670
查看次数

标签 统计

objective-c ×2

calayer ×1

core-graphics ×1

ios ×1

ios8 ×1

mask ×1

uikit ×1

uiview ×1