我有下面的代码测试,但是当我给它的约束,它变成一个小圆圈:
override func drawRect(rect: CGRect) {
var path = UIBezierPath(ovalInRect: rect)
fillColor.setFill()
path.fill()
//set up the width and height variables
//for the horizontal stroke
let plusHeight:CGFloat = 300.0
let plusWidth:CGFloat = 450.0
//create the path
var plusPath = UIBezierPath()
//set the path's line width to the height of the stroke
plusPath.linewidth = plusHeight
//move the initial point of the path
//to the start of the horizontal stroke
plusPath.movetoPoint(CGPoint(
x:self.bounds.width/2 - plusWidth/2 + 0.5,y:self.bounds.height/2 + 0.5))
//add a point to the path at the end of the stroke
plusPath.addLinetoPoint(CGPoint(
x:self.bounds.width/2 + plusWidth/2 + 0.5,y:self.bounds.height/2 + 0.5))
}
根据需要更改半径和fillColor.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。