title: How will work addSublayer and renderInContext in iOS
body: <p>When i have written code as following way.. </p>
  
  <pre><code>- (void)drawRect:(CGRect)rect
  {
      CGContextRef context = UIGraphicsGetCurrentContext();
      CGContextSetBlendMode(context, kCGBlendModeDifference);
  
      sublayer = [CALayer layer];
      sublayer.backgroundColor = [UIColor redColor].CGColor;
      sublayer.opaque = NO;
      sublayer.frame = CGRectMake(30, 30, 250, 200);
      [sublayer renderInContext:context];
  
      sublayer1 = [CALayer layer];
      sublayer1.opaque = NO;
      sublayer1.backgroundColor = [UIColor greenColor].CGColor;
      sublayer1.frame = CGRectMake(120, 120, 100, 250);
      [sublayer1 renderInContext:context];
  
  }
  </code></pre>
  
  <p>I got as following first image as </p>
  
  <p><img src="https://i.stack.imgur.com/HnYMI.png" alt="enter image description here">           <img src="https://i.stack.imgur.com/6Uf1n.png" alt="enter image description here"></p>
  
  <p>The positions of sublayer, sublayer1 are not correct way because i have set frames to them. The intersection of them is blended color. Why are they  not set the actual position? </p>
  
  <p>But when i use <code>addSublayer</code>, i got as above second image. Here the positions of sublayer, sublayer1 are correct way. The intersection of them is not blended color. What happened like that. </p>
  
  <p>Why i created sublayer is, when i drag sublayers the intersection part of them has to be blended color. Please anyone explain to me.</p>
  
  <p>Thanks in Advance.</p>