enter image description here所以我有backgroundView(UIView)和两个按钮。 现在我做了以下代码
buttonBackgroundView.layer.cornerRadius = 5.0
buttonBackgroundView.layer.borderColor = UIColor.black.cgColor
buttonBackgroundView.layer.borderWidth = 0.5
@IBOutlet weak var firstbutton: UIButton!{
didSet{
proceedButton.clipsToBounds = true
}
}
在此视图中具有圆角,但是按钮没有那些圆角 我该如何实施? (这样该按钮也会获得圆角。 我有两个按钮,所以我只想要左按钮的左上角和右按钮的右上角。
我添加了我想要实现的图像链接。
答案 0 :(得分:0)
请尝试使用masksToBounds
属性,
@IBOutlet weak var firstbutton: UIButton!{
didSet{
proceedButton.clipsToBounds = true
proceedButton.masksToBounds = true
}
}
答案 1 :(得分:0)
class ViewController: UIViewController {
@IBOutlet weak var yourView: UIView! //Create your view outlet
override func viewDidLoad() {
super.viewDidLoad()
yourView.clipsToBounds = true
yourView.layer.cornerRadius = 15 // As per you requirement
yourView.layer.borderColor = UIColor.black.cgColor
yourView.layer.borderWidth = 2
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
这可能会帮助您:)