gpt4 book ai didi

ios - Swift 左侧仅带边框的圆形按钮

转载 作者:行者123 更新时间:2023-11-28 11:47:54 26 4
gpt4 key购买 nike

我怎样才能得到这种下拉菜单?

我正在使用按钮。能够得到圆角,但左边的边界是圆的,右边的边界是直的是一个问题

最佳答案

您可以按照以下步骤来实现您想要的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 添加边框。

关于ios - Swift 左侧仅带边框的圆形按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52233303/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com