1

I am designing one of the screen which has quite complex UI.

The UIView has dashed-line in middle with arc on right and left side.

Please check below picture for better understanding.

Can anyone guide me how to achieve such design in iOS?

enter image description here

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Aman.Samghani
  • 2,151
  • 3
  • 12
  • 27
  • I'd say: It's just a mask, and I'd go with UIBezierPath to draw the mask. – Larme Nov 13 '17 at 10:23
  • Can you please guide me how to do so? – Aman.Samghani Nov 13 '17 at 10:24
  • https://stackoverflow.com/questions/43668491/using-an-uiview-as-a-mask-in-another-uiview-on-swift (to know how to mask). For the rest, look for UIBezierPath there should be some tutorial. You won't find the exact shape you want, but rather how to use it. – Larme Nov 13 '17 at 10:25

1 Answers1

0

Use this code to create a dashed line with custom parameters:

let  path = UIBezierPath()

let  point1 = CGPointMake(CGRectGetMinX(self.bounds),CGRectGetMidY(self.bounds))
path.moveToPoint(point1)

let  point2 = CGPointMake(CGRectGetMaxX(self.bounds),CGRectGetMidY(self.bounds))
path.addLineToPoint(point2)

let  dashes: [CGFloat] = [12.0, 24.0]
path.setLineDash(dashes, count: dashes.count, phase: 0.0)

path.lineWidth = 10.0
path.lineCapStyle = .Butt
UIColor.greenColor().set()
path.stroke()

For framing just use a rectangle and a circle (you'll get an arc).

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220