【发布时间】:2015-08-20 00:28:19
【问题描述】:
我正在尝试制作一个带边框的 UIView,但我只让它出现在 UIView 中,而不仅仅是在圆圈上。
在棕色圆圈中我想要一个黑色边框,但它必须在圆圈中而不是在 UIView 中。
我有一个名为 Ball 的类,我在其中画圆。
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()
}
}
我使用了代码:
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()
}
但我得到了一个带有一点切口的边框:
【问题讨论】:
-
不清楚你想要达到的目标。
-
@matt 我改进了这个问题,看看你现在能不能理解
标签: ios swift uiview uibezierpath