title: dashed border UIImageView swift
body: <p>I'm trying to add a dashed border using <code>CALayer</code> on a <code>UIImageView</code>. I've found a method, but is that working in swift and how can i convert it to swift? o have another imageView which has a border so would be the best solution to use <code>CALayer</code>, so they look similar? How can i obtain this</p>
  
  <p>obj-c code to swift?</p>
  
  <pre><code>- (CAShapeLayer *) addDashedBorderWithColor: (CGColorRef) color {
      CAShapeLayer *shapeLayer = [CAShapeLayer layer];
  
      CGSize frameSize = self.size;
  
      CGRect shapeRect = CGRectMake(0.0f, 0.0f, frameSize.width, frameSize.height);
      [shapeLayer setBounds:shapeRect];
      [shapeLayer setPosition:CGPointMake( frameSize.width/2,frameSize.height/2)];
  
      [shapeLayer setFillColor:[[UIColor clearColor] CGColor]];
      [shapeLayer setStrokeColor:color];
      [shapeLayer setLineWidth:5.0f];
      [shapeLayer setLineJoin:kCALineJoinRound];
      [shapeLayer setLineDashPattern:
      [NSArray arrayWithObjects:[NSNumber numberWithInt:10],
      [NSNumber numberWithInt:5],
    nil]];
      UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:shapeRect cornerRadius:15.0];
      [shapeLayer setPath:path.CGPath];
  
      return shapeLayer;
  }
  </code></pre>