I want to add a floating close (x) button at the corner of an UIModalPresentationPageSheet
View. The effect is like below:
But adding it to the parent view makes it appear behind the Page Sheet (and also impossible to tap) and adding it to the Page Sheet will make part of it hidden, since it's out of the view area.
Is there any better solution?
Any suggestions are appreciated.
See if this works:
myPresentedView.clipsToBounds = NO;
That will allow the button to draw itself beyond it's views. One drawback to this is that the touches will not land beyond the views bounds, so try not to set the button too far away.
You can try and add it to the the topmost application window:
This should give you the right view to allow the button to appear on top of the modal and receive touch events.
--edit--
To position the button you can try something like this:
This will get the frame of the modalView that has been presented. You can then set your button's origin to be offset and set the adjusted frame.