Reputation: 5388
I searched a lot over the internet to find the right solution to convert my constant .h file to swift. I already tried these links
These both are use full but not completely solved my problem.
I just want to convert these three #define to swift all other can be converted in the same way as these will do.
#define IS_IPHONE_4S [[UIScreen mainScreen] bounds].size.height == 480
#define IOS7VERSION ([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0?YES:NO)
#define RGBCOLOR(r, g, b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
Upvotes: 3
Views: 3748
Reputation: 7935
You can use the keyword let
for this.
For example:
let IsIPhone4S = UIScreen.mainScreen().bounds.height == 480
let IOS7Version = Float(UIDevice.currentDevice().systemVersion) >= 7
And for the last case you should use function:
func RGBColor(red: CGFloat, green: CGFloat, blue: CGFloat) -> UIColor {
return UIColor(red: red / 255, green: green / 255, blue: blue / 255, alpha: 1)
}
Upvotes: 3