 <p>Put your code in an <code>override</code> of <code>layoutSubviews</code> so that it uses the updated bounds:</p> <pre><code>override func layoutSubviews() { super.layoutSubviews() let maskLayer = CAShapeLayer() maskLayer.path = UIBezierPath(roundedRect: bounds, byRoundingCorners: [.BottomLeft, .BottomRight], cornerRadii: CGSizeMake(20, 20)).CGPath self.layer.mask = maskLayer } </code></pre>