LoginSignup
2
1

More than 3 years have passed since last update.

【Swift】Argument labels '(_:, _:)' do not match any available overloadsなるエラーが出た

Last updated at Posted at 2017-11-27
1 / 2

Argument labels '(_:, _:)' do not match any available overloadsなるエラーが出た

ただの備忘録

今回のエラーコード


class drawPicView: UIView {

    var l: CGFloat!
    var r: CGFloat!

    override func awakeFromNib() {
        super.awakeFromNib()

        l = frame.size.width / 3
        r = sqrt(1.5 * 1.5 + 0.5 * 0.5) * l
    }

override func draw(_ rect: CGRect) {

        self.yellowArc()
    }

private func yellowArc() {
let path = UIBezierPath(
            arcCenter: CGPoint(l * 1.5, l * 1.5),
            radius: r,
            startAngle: 0,
            endAngle: CGFloat(M_PI_2),
            clockwise: true)
        path.addLine(to: CGPoint(l * 2, l * 2))
    }
}

違和感無かったけど(なぜ)、xとかyが入ってない...
ここ↓

private func yellowArc() {
let path = UIBezierPath(
            arcCenter: CGPoint(l * 1.5, l * 1.5),
            radius: r,
            startAngle: 0,
            endAngle: CGFloat(M_PI_2),
            clockwise: true)
        path.addLine(to: CGPoint(l * 2, l * 2))
    }

訂正後


let path = UIBezierPath(
            arcCenter: CGPoint(x: l * 1.5,y l * 1.5),
            radius: r,
            startAngle: 0,
            endAngle: CGFloat(M_PI_2),
            clockwise: true)
        path.addLine(to: CGPoint(x: l * 2, y: l * 2))

昔のオープンソースコードから取ってきたコードは注意

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1