Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIView border cover sub-view?

I have a UIView which includes a UIButton which is partially on UIView. I have a problem when I draw a border on my UIView. Please have a look at my screenshot:

enter image description here

You can see the border is above the UIButton, why? Can anybody suggest? Thanks

like image 320
Bagusflyer Avatar asked Mar 30 '13 03:03

Bagusflyer


1 Answers

Thanks for aăâ, I found a solution.

  1. Basically the border is always drawn on top of everything
  2. What I did is:

    • Create a UIView with color of border
    • Create another UIView as the child the main UIView which is a little bit smaller than the first one. The color of this newly create UIView is the main color

Here is the code:

self.layer.cornerRadius = 15;
self.layer.masksToBounds = YES;
self.backView.layer.cornerRadius = 15;
self.backView.layer.masksToBounds = YES;

The result is:

enter image description here

It's more or less what I need although it's not perfect.

like image 71
Bagusflyer Avatar answered Oct 08 '22 17:10

Bagusflyer