剪辑按钮查看

时间:2018-12-24 14:51:22

标签: ios iphone uibutton swift4

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
        }
    }

在此视图中具有圆角,但是按钮没有那些圆角 我该如何实施? (这样该按钮也会获得圆角。 我有两个按钮,所以我只想要左按钮的左上角和右按钮的右上角。

我添加了我想要实现的图像链接。

2 个答案:

答案 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.
    }


}

添加以下约束 Storyboard with Constraints

输出: enter image description here

这可能会帮助您:)