Reputation: 4462
I am trying to add a few buttons in the code and i get an error "Extra argument "width" in call"
let yPos = txt.frame.origin.y + txt.frame.height
for i in 0..<count {
let yt : Int = i*40 + yPos
//let b = UIButton(frame: CGRect(x: xPos, y: 40, width: 100, height: 30))
var b = UIButton(frame: CGRect(x: xPos, y: yt, width: 100, height: 30))
b.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "test:"))
b.backgroundColor = UIColor.blackColor()
b.tag = i
self.addSubview(b)
}
I cant figure out what is the problem. I tried to cast all the argument to Int but i get the same error. Any suggestions?
Upvotes: 0
Views: 1534
Reputation: 4462
my mistake i had to cast all the arguments to CGFloat
for i in 0...2 {
let yt : CGFloat = CGFloat(i*40) + yPos
//let b = UIButton(frame: CGRect(x: xPos, y: 40, width: 100, height: 30))
var b = UIButton(frame: CGRect(x: xPos, y: yt, width: 100, height: 30))
b.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "test:"))
b.backgroundColor = UIColor.blackColor()
b.tag = i
self.addSubview(b)
}
Upvotes: 3