Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using variables in CGRectMake, Swift, UIkit

For an App I'm making i need to use variables to change the size and position of objects (Labels). I've tried var example = CGRectMake(0, 0, 0, 100), hoping it would ignore the zeros (Not really thinking it would though). I then tried:

var example = 100
Label1.frame = CGRectMake(20, 20, 50, example)

I changed the syntax a bit, adding "" and replacing the CGRectMake with CGRect etc, but nothing worked... I don't get what I'm doing wrong here... Help!

like image 782
Mats Avatar asked Jun 07 '15 09:06

Mats


1 Answers

Swift 3 update

let rect = CGRect(x: 0, y: 0, width: 100, height: 100)
like image 121
quemeful Avatar answered Sep 30 '22 14:09

quemeful