Q:

How to fit CAShapeLayer

I`m developing iPhone app, where i using next code to round two corners of my layer :
CAShapeLayer *backgroundMaskLayer = [CAShapeLayer layer];
UIBezierPath *backgroungMaskPath = [UIBezierPath
                                    bezierPathWithRoundedRect:self.layer.bounds
                                    byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                    cornerRadii:CGSizeMake(10.0, 10.0)];

self.clipsToBounds = NO;
backgroundMaskLayer.frame = self.layer.bounds;
backgroundMaskLayer.path = backgroungMaskPath.CGPath;
backgroundMaskLayer.lineWidth = 2.0;
backgroundMaskLayer.strokeColor = [UIColor whiteColor].CGColor;
backgroundMaskLayer.fillColor = [UIColor whiteColor].CGColor;

[self.inputBackView.layer addSublayer:backgroundMaskLayer];

But circled layer doesn`t scale with other layers on different devices.
I`ve tried this:
backgroundMaskLayer.contentsScale = [UIScreen mainScreen].scale;
backgroundMaskLayer.rasterizationScale = [UIScreen mainScreen].scale;
backgroundMaskLayer.shouldRasterize = YES;

and this:
- (void)layoutSubviews {
  mylayer.frame = self.bounds;
  }

Also ive tried to make different combinations of constraints, but im still getting this on iPhone 6 (on iPhone 5, it is pretty enough):

where blue colour is my layer in xib file, on which I impose my CAShapeLayer * backgroundMaskLayer (white colour).
How can i fix it?

A:

Update your layoutSubviews method as:
- (void)layoutSubviews
{
    [super layoutSubviews];
    UIBezierPath *backgroungMaskPath = [UIBezierPath
                                        bezierPathWithRoundedRect:self.bounds
                                        byRoundingCorners:UIRectCornerTopLeft | UIRectCornerTopRight
                                        cornerRadii:CGSizeMake(10.0, 10.0)];
    backgroundMaskLayer.path = backgroungMaskPath.CGPath;

}

