Reputation: 69
How can i get this kind of dropdown ?
I'm using button. Able to get rounded corners but border on left to be round and straight on right is a problem
Upvotes: 0
Views: 1062
Reputation: 66
you can follow below steps to achieve the layout of Dropdown you want.
1.Use UITableView for dropdown.
2.Create a UITableViewCell.
3.Add Rounded Corner to the UIView on one side.
let rectShape = CAShapeLayer()
rectShape.bounds = self.roundedView.frame
rectShape.position = self.roundedView.center
rectShape.path = UIBezierPath(roundedRect: self.roundedView.bounds, byRoundingCorners: [.bottomLeft , .topLeft], cornerRadii: CGSize(width: 20, height: 20)).cgPath
self.roundedView.layer.backgroundColor = UIColor.purple.cgColor
//Here I'm masking the textView's layer with rectShape layer
self.roundedView.layer.mask = rectShape
4. Add border to roundedView.
Upvotes: 3