Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Defining constant for screen width

I have a constant defined with screen width to 320. This is being used at multiple places in my code. I have to change this to take value from current device and I do not want to touch all these places. So, I want to define a constant for this with value:

[[UIScreen mainScreen] bounds].size.width

#define kScreenWidth [[UIScreen mainScreen] bounds].size.width

But it is giving me lot of compilation errors. Any clue?

like image 324
Abhinav Avatar asked Jan 21 '23 11:01

Abhinav


1 Answers

[[UIScreen mainScreen] applicationFrame].size.width
like image 197
Mark Adams Avatar answered Jan 31 '23 00:01

Mark Adams