Wednesday, June 5, 2024
HomeiOS Developmentios - How you can give margin to dotted line divider in...

ios – How you can give margin to dotted line divider in swift?


enter image description here

I need to make the desk view divider line dotted and add a margin on the left.
The supply is beneath and I attempted adjusting the x of shapeRect, botttomShapeLayer.positon, and UIBezierPath, however was not profitable.
How can I give margin on the left whereas sustaining the dotted line?
Additionally, the supply code beneath has an area on the correct aspect. Can this house be eliminated?
I solved the issue by including 100 to the width as a shortcut.

let botttomShapeLayer = CAShapeLayer()
let frameSize = cell.body.dimension
let shapeRect = CGRect(x: 0, y: 0, width: frameSize.width, peak: 0)

botttomShapeLayer.bounds = shapeRect
botttomShapeLayer.place = CGPoint(x: frameSize.width/2, y: frameSize.peak)
botttomShapeLayer.fillColor = UIColor.clear.cgColor
botttomShapeLayer.strokeColor = UIColor.black.cgColor
botttomShapeLayer.lineWidth = 2.0
botttomShapeLayer.lineDashPattern = [4,4]
botttomShapeLayer.path = UIBezierPath(roundedRect: CGRect(x: 0, y: shapeRect.peak, width: shapeRect.width, peak: 0), cornerRadius: 0).cgPath

cell.layer.addSublayer(botttomShapeLayer)



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments