title: Border in circle UIView using Swift
body: <p>I'm trying to make an UIView with border but I only make it appear in UIView not only on the circle.</p>
  
  <p><a href="https://i.stack.imgur.com/ezrR3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ezrR3.png" alt="sample"></a></p>
  
  <p>In the brown circle I want a black border, but it has to be in the circle not in the UIView.</p>
  
  <p>I have a class called Ball where I draw the circle. </p>
  
  <pre><code>class Ball: UIView {
  
      var desiredColour = UIColor.blueColor()
  
      struct mine {
          static var p = UIBezierPath(ovalInRect: CGRectMake(0,0,118,117))
  
      }
  
      override func drawRect(rect: CGRect) {
          // Drawing code
  
  
          desiredColour.setFill()
          mine.p.fill()
  
      }
  
  
      func colour() {
  
          var randColor: UIColor = Colors.randomColor()
  
          Colors.ballColor = randColor
          Colors.colorPosition = find(Colors.arrayColors, randColor)!
  
          desiredColour = randColor
          self.setNeedsDisplay()
  
      }
  }
  </code></pre>
  
  <p>I used the code:</p>
  
  <pre><code>override func drawRect(rect: CGRect) {
      // Drawing code
  
  
      desiredColour.setFill()
  
      let desiredBorderColor = UIColor.blackColor()
      desiredBorderColor.setStroke()
  
      self.layer.borderWidth  = 3.0
      self.layer.cornerRadius = self.frame.size.width/2.0
  
      mine.p.fill()
      mine.p.stroke()
  
  }
  </code></pre>
  
  <p>but i get a border with a little cuts:</p>
  
  <p><a href="https://i.stack.imgur.com/MEuHS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MEuHS.png" alt="enter image description here"></a></p>