I have a custom class that adds a border to my button and has a function to create the “X” button in the upper lefthand corner.
First problem: In order for the X button to appear outside the bounds of the image button, I have to tun off clipToBounds on the image button. But that has the negative side effect of allowing the image to poke through the rounded corners. Is there a way to clip just the image and not the X button?
Second problem: The border is showing over the X button. (I thought it was an alpha problem at first, but it is not.) I’m hoping the solution to the first problem will solve the second one which is why I’m addressing both here.
I'd suggest creating a new view and add the x button and image view as subviews. This view will not clip to bounds. Then set the border, corner radius and clipToBounds on the image view.