Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Binary operator * cannot be applied to operands of type Int and CGFloat

Tags:

ios

swift

i had type Int. please help me fix that?

enter image description here

like image 511
lee Avatar asked Jul 31 '15 03:07

lee


2 Answers

Instead of i * self.view.frame.size.width, use CGFloat(i) * self.view.frame.size.width

like image 88
Epic Defeater Avatar answered Nov 03 '22 17:11

Epic Defeater


You need to type cast i into CGFloat, write your line of code as

var frame: CGRect = CGRectMake(CGFloat(i) * self.view.fram.size.width, self.tutorialHolderView.frame.origin.y, 0, self.tutorialHolderView.frame.size.height)

like image 30
Chetan Avatar answered Nov 03 '22 17:11

Chetan