ios - Swift 左侧只有带边框的圆形按钮
问题描述
我怎样才能得到这种下拉菜单?
我正在使用按钮。能够得到圆角,但左边的边界是圆的,右边是直的是一个问题
解决方案
您可以按照以下步骤来实现您想要的 Dropdown 布局。
1.使用 UITableView 进行下拉。
2.创建一个UITableViewCell。
3.向一侧的UIView添加圆角。
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.给roundedView添加边框。
推荐阅读
- android - 获取 java.lang.IllegalStateException: Binder 已完成!当调用 disconnect() 或 close() android.bluetooth.BluetoothGatt
- amazon-web-services - TypeError:无法修改 PDF 文件,请确保输出文件目标可用且不受保护
- wordpress - Wordpress ACF 以编程方式向灵活内容添加行
- android - 需要一些关于键盘隐藏代码的建议
- node.js - 如何在 Expressjs 中创建拦截器以发送每个请求的令牌,并在 Angular 6 过期时刷新令牌
- python - 我想提取每个主题的名称和每个视频的名称
- angular - 在我以角度导出到 excel 后,数据已损坏且无法打开 excel 文件
- node.js - 如何将root挂载到express目录?
- vaadin - 如何修复网格中的对象集?
- javascript - 尝试使用 AJAX 获取函数参数并传递给 PHP 代码