gpt4 book ai didi

ios - round bottomRight 与 byRoundingCorners 不起作用

转载 作者:行者123 更新时间:2023-11-28 07:20:10 24 4
gpt4 key购买 nike

我正在尝试为 topLeft 和 rightBottom 制作圆角,顶部圆形效果很好但 leftBottom 仍然是矩形,

我搜索了很多,我认为这是重叠问题,但不知道如何解决,请帮忙?

附言仅在 iPhone Xs Max 中运行良好

import UIKit

@IBDesignable
class CustomView: UIView {

override init(frame: CGRect) {
super.init(frame: frame)
setRadius()

}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setRadius()
}
override func prepareForInterfaceBuilder() {
setRadius()
}
func setRadius()
{
let cornerRadius = 18.0

let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: [.topLeft, .bottomRight], cornerRadii: CGSize(width: cornerRadius, height: cornerRadius))

let maskLayer = CAShapeLayer()
self.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
maskLayer.frame = self.bounds
maskLayer.path = path.cgPath
self.layer.mask = maskLayer
}
}

最佳答案

试试这个

let your_Frame = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100))//define your frame size you want
your_Frame.layer.cornerRadius = 25//deine the radius you want
your_Frame.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMaxYCorner]
view.addSubview(your_Frame)

关于ios - round bottomRight 与 byRoundingCorners 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58468688/

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