2

I don't understand why a simple view, with only cornerRadius property set to an arbitrary value, works perfectly, while as soon as i override drawRect ( also trying to call super.drawRect() ) cornerRadius doesn't work anymore. The solution is to set self.layer.masksToBounds property to true, but i don't understand the structure of what happens behind the code, such as what functions are called first. The documentation about cornerRadius doesn't help me.

Any suggestions/explanation ?

Thx

Michał Ciuba
  • 7,876
  • 2
  • 33
  • 59
diningphil
  • 416
  • 5
  • 18
  • 1
    Why do you want to override `drawRect`? What do you want to achieve with it? It's often not necessary to do so. – Michał Ciuba Jan 29 '15 at 18:39
  • when you override drawrect, you indicate that you are going to render the view. Either set all the property to the view and allow the framework to render or override the drawrect and render the way you want. – nprd Jan 29 '15 at 19:39
  • ok Naveen, but how can you explain the fact that setting masksToBounds true makes cornerRadius works although i decided to override drawRect? Michal i'm just practising with a custom view. – diningphil Jan 29 '15 at 21:07

0 Answers0