2017-06-02 63 views
2

我想在矩形的每一邊的邊緣創建一個小圓圈,而不是隻有一個角。 我做一個標籤,設置:在矩形的每一條邊上創建圓形

exampleLabel.layer.borderWidth = 2.0 

exampleLabel.layer.borderColor = UIColor.black.cgColor 

enter image descriptiond here

因此,要獲得這樣的形狀:

enter image description here

回答

1

還可以繪製在每個角落的圓。

let circle = UIView(frame: CGRect(x: -2.5, y: -2.5, width: 5.0, height: 5.0)) 
    circle.layer.cornerRadius = 2.5 
    circle.backgroundColor = UIColor.black 
    self.exampleLabel.addSubview(circle) 

這是一個在左上角的圓圈。你也可以爲左下/右上/右下。

您可以通過x和y值的位置發揮

讓我知道這是你想要的

+0

是的,感謝ü:)我會做同樣的其他3個邊:P – RosS

+0

幹得好! @RosS – Gregga17