If there is no specific requirement that we do not know about, a path without a mask and a mask are not needed, if all you are trying to do is round corners and have a border. Usually I just do this: myView.layer.borderWidth = 2; myView.layer.cornerRadius = 5;
Is it only necessary that the top corners be rounded, that you do not need to use rounding of the layer? If so, why not use this and then impose a subtle look to cover the bottom bit? A bit unrealistic, but I find that the more you can rely on standard controls to draw yourself, rather than enter into the main graphics, the better.
Edit : ok, given that this requires the bottom corners not to be rounded, how about whether you had a category on a UIView with two subzones: 1 with 4 rounded corners and the other at the top (self bringSubviewToFront), which just covers rounded view "footer" with a non-circular strip, that is, a view with equal width and tiny height equal to the rounded corner radius. If you have a solid background color, then just make both subviews the same; if you have a texture or image background, make it transparent and put the texture / image in a super view (the parent view using your layout method of a certain category). Then finally put the border on the same supervisor. Should work, let me know what you think.
source share