0

I have an app in which there are so many popover and every popover so many objects like UIButtons, UILable,UITableView.

Now I want to create view like popover using UIBezierpathswith upside arrow.

How can I do that in a UIView?

don't want to any third party tool.

Any help will be appreciated.

princ___y
  • 1,089
  • 1
  • 9
  • 27
Maulik shah
  • 1,664
  • 1
  • 19
  • 45

2 Answers2

0

Check my answer from link here and just change the point values according to your need or path.

Hope it will help you.

Community
  • 1
  • 1
Ganesh G
  • 1,991
  • 1
  • 24
  • 37
0

I am late but could be helpful to someone

func drawPopoverRadius(text: String) -> UIView {

    let layer = CAShapeLayer()
    let path = UIBezierPath()
    path.move(to: .zero)
    path.addLine(to: CGPoint(x: 51, y: 0))
    path.addLine(to: CGPoint(x: 51, y: 48))
    path.addLine(to: CGPoint(x: 51/2 - 4, y: 48))
    path.addLine(to: CGPoint(x: 51/2, y: 52))
    path.addLine(to: CGPoint(x: 51/2 + 4, y: 48))
    path.addLine(to: CGPoint(x: 0, y: 48))
    path.close()
    layer.path = path.cgPath
layer.fillColor = UIColor.gray.cgColor
    layer.anchorPoint = .zero
    layer.name = "popover"
    let label = UILabel(frame: CGRect(x: 0, y: 0, width: 51, height: 52))
    label.clipsToBounds = false
    label.numberOfLines = 0
    label.font = NunitoSans.regular.font(size: 14)
    label.textColor = .white
    label.text = text
    label.layer.addSublayer(layer)
    return label
}
Syed Ali Salman
  • 2,894
  • 4
  • 33
  • 48