I'm trying to make an UIView with border but I only make it appear in UIView not only on the circle.
In the brown circle I want a black border, but it has to be in the circle not in the UIView.
I have a class called Ball where I draw the circle.
class Ball: UIView {
var desiredColour = UIColor.blueColor()
struct mine {
static var p = UIBezierPath(ovalInRect: CGRectMake(0,0,118,117))
}
override func drawRect(rect: CGRect) {
// Drawing code
desiredColour.setFill()
mine.p.fill()
}
func colour() {
var randColor: UIColor = Colors.randomColor()
Colors.ballColor = randColor
Colors.colorPosition = find(Colors.arrayColors, randColor)!
desiredColour = randColor
self.setNeedsDisplay()
}
}
I used the code:
override func drawRect(rect: CGRect) {
// Drawing code
desiredColour.setFill()
let desiredBorderColor = UIColor.blackColor()
desiredBorderColor.setStroke()
self.layer.borderWidth = 3.0
self.layer.cornerRadius = self.frame.size.width/2.0
mine.p.fill()
mine.p.stroke()
}
but i get a border with a little cuts:
Try calling this function by passing you view as a parameter
func drawBlackBorder(view: UIView) {
view.layer.borderColor = UIColor.blackColor
view.layer.borderWidth = 1.0
view.layer.cornerRadius = view.frame.size.width/2.0
view.backgroundColor = UIColor.brownColor
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With