SG Prasanth
SG Prasanth

Reputation: 69

Swift Left Side only rounded button with border

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

Answers (1)

Nilesh Solanki
Nilesh Solanki

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

Related Questions