search

Home  >  Q&A  >  body text

ios - UIImageView 添加了layer mask,想要给mask增加inset

最近在做拼图,参考的linecamera, 怎么设置inset呢。

追加问题: 现在出现一个新的问题, 我要改变北京色为图片, 这时候就有问题了,不能是layer压在上面了, 需要用这个layer去做整体的mask,但是,layer的stroke color 设置为透明,fill 黑色,mask之后显示出来的部分只有一半。 因为fill会填充stroke的一半。。。。

PHPzPHPz2771 days ago731

reply all(2)I'll reply

  • 天蓬老师

    天蓬老师2017-04-18 09:47:34

    Actually, I made this problem complicated myself, and it can be solved by adding a borderLayer.
    First subtract the borderwidth from the size of the canvas, construct the path based on the Size, get the borderLayer, and add it.
    It’s actually very simple, but there are a lot of things associated with it. There are shapes, editpoints, and other elements on the canvas, and their positions need to be recalculated based on the borderWidth.

    reply
    0
  • ringa_lee

    ringa_lee2017-04-18 09:47:34

    Use all gray as the background color, cover it with red and green, and set the view.layer.mask twice to meet the requirements of CAShapeLayer(). Isn’t it quite convenient?

    reply
    0
  • Cancelreply