It does not look like UIButton instrinsicSize and / or sizeToFit is considering the left-margin insert, or something is confused with my expectations.
To demonstrate, I have two custom type buttons in the view, as with the "Button" header. I want to add an image to the button to the left of the title.
var image = UIImage(named: "circledPlay") image = image?.imageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate) self.button1.setImage(image, forState: UIControlState.Normal) self.button1.invalidateIntrinsicContentSize() self.button1.sizeToFit() self.button2.setImage(image, forState: UIControlState.Normal) self.button2.titleEdgeInsets = UIEdgeInsetsMake(0, 10, 0, 0) self.button2.invalidateIntrinsicContentSize() self.button2.sizeToFit()
The result is as follows:

Notice that the second button is truncated.
So my question would be if someone had seen this before (and hopefully has a solution), or am I confused, and it behaves as expected (and hopefully knows the right way to do this)?
source share