 <p>If you use XIBs make mask for your subviews as shown here:</p> <p><img src="https://i.stack.imgur.com/Av5v6.png" alt="Center without resizing of subviews"></p> <p>or here:</p> <p><img src="https://i.stack.imgur.com/xOduO.png" alt="Center with resizing of subview"></p> <p>If you prefer to use code use posted one by @adali.</p>