title: add border in CGRect iOS
body: <p>I want to add a border in a CGRect. Although previous solutions suggest either this:</p>
  
  <pre><code>CGContextRef context = UIGraphicsGetCurrentContext();
      CGContextSetRGBFillColor(context, 1.0, 0.0, 0.0, 1.0);
      CGContextSetRGBStrokeColor(context, 1.0, 0.0, 0.0, 1.0);
      CGContextFillRect(context, rectangle);
  </code></pre>
  
  <p>or something like this:</p>
  
  <pre><code>view.layer.borderWidth = 10;
  view.layer.borderColor = [UIColor redColor].CGColor;
  </code></pre>
  
  <p>I cannot apply either of this in my approach.</p>
  
  <p>In my mainView Controller I am having this code:</p>
  
  <pre><code>-(void)actionHint
  {
      CGRect  viewRect = CGRectMake(kScreenWidth/2 -kMenuWidth, kScreenHeight/2-kMenuHeight - 70,kMenuWidth*10, kMenuHeight*4);
      HintMenu* hintMenu = [HintMenu viewWithRect:viewRect];
      [hintMenu.btnReveal addTarget:self action:@selector(actionReveal) forControlEvents:UIControlEventTouchUpInside];
      [hintMenu.btnNewAnag addTarget:self action:@selector(actionNewAnagram) forControlEvents:UIControlEventTouchUpInside];
      [self.gameView addSubview:hintMenu];
  }
  </code></pre>
  
  <p>I am creating a game and I want a simple rect with some help actions to come on top of my current view. The code for viewRect is:</p>
  
  <pre><code>+(instancetype)viewWithRect:(CGRect)r
  {
      HintMenu* hint = [[HintMenu alloc] initWithFrame:r];
      hint.userInteractionEnabled = YES;
  
      UIImage* image=[UIImage imageNamed:@"btn"];
      ... rest of items in the cgrect
      return hint;
  }
  </code></pre>
  
  <p>Where should I add the code for adding the borders and what that code should be?</p>