title: Custom border for UIView using CALayer and autolayout
body: <p>I have to draw a custom border for a UIView. </p>
  
  <p>I already have code to do that but it was written before we started using autolayout.</p>
  
  <p>The code basically adds a sublayer of width/height=1.0f</p>
  
  <pre><code>-(void)BordeIzquierdo:(UIColor *)pcColor cfloatTamanio:(CGFloat )pcfloatTamanio
  {
      CALayer* clElemento = [self layer];
      CALayer *clDerecho = [CALayer layer];
      clDerecho.borderColor = [UIColor darkGrayColor].CGColor;
      clDerecho.borderWidth = pcfloatTamanio;
      clDerecho.frame = CGRectMake(0, 1, pcfloatTamanio, self.frame.size.height);
      [clDerecho setBorderColor:pcColor.CGColor];
      [clElemento addSublayer:clDerecho];
  }
  </code></pre>
  
  <p>Now the problem is that with autolayout, this happens before layoutSubViews. So <code>UIView.layer.frame</code> is (0,0;0,0) and so the sublayer added is not shown because it has width/height=0.0f</p>
  
  <p>Now how can I make this code without transferring this custom drawing to another method executed after <code>viewDidLoad</code> such as <code>didLayoutSubviews</code>.</p>
  
  <p>I would like this styling to be correctly applied before <code>viewDidLoad</code> is called.</p>
  
  <ul>
  <li>Is there anything like autolayout constraints that I can use with <code>CALayers</code>?</li>
  <li>Any other ideas? </li>
  </ul>