I am having a UIView
which contains other subviews. I am applying border to this UIView
and the border is applied to the whole UIView
. For that see the first image.
But do not want the border around the title where it says "Leaderboard"
. How can i remove the border for that portion only. See the below image and in that see that there is no border around the header Leaderboard..
You can subclass the
UIView
and implement thedrawRect
like:Now, you need to use the subclassed
UIView
for creating the needed view.NO,
CALayer
borders don’t support that behavior.But you can try an alternate method if you need to implement this, try adding an n-point-wide opaque subview with your desired border color as its background color, on each side of your main view.
Add this Code:
This will add borders to both sides only.Repeat the same idea for top and bottom also.
NB :
heightfromTop
is the height of the top section where you don't want the border view to be present, you can alter it as per your needs