Monday, October 13, 2014

detecting iOS, iPhone, iPad and apple watch

detecting iOS, iPhone, iPad and apple watch

// detecting iOS


NSString *version = [[UIDevice currentDevice] systemVersion];
NSLog(@"Version:%@",version);

//detecting iPhone



add these line to your .h file

#define IS_IPHONE_4 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)480) < DBL_EPSILON)
#define IS_IPHONE_5 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)568) < DBL_EPSILON)
#define IS_IPHONE_6 (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)667) < DBL_EPSILON)
#define IS_IPHONE_6_PLUS (fabs((double)[[UIScreen mainScreen]bounds].size.height - (double)736) < DBL_EPSILON)


and use it in your .m file

if (IS_IPHONE_4)
        NSLog(@"iPhone 4");
else if (IS_IPHONE_5)
        NSLog(@"iPhone 5");

//detecting iPad


if ([UIDevice currentDevice].userInterfaceIdiom != UIUserInterfaceIdiomPad)
{
        //code for iPad
}

//detecting apple watch

add these line to your .h file

#define IS_WATCH_42 (fabs((double)self.contentFrame.size.height - (double)174) < DBL_EPSILON)

#define IS_WATCH_38 (fabs((double)self.contentFrame.size.height - (double)151) < DBL_EPSILON)


and use it in your .m file

if (IS_WATCH_42)
        NSLog(@"apple watch 42mm");
    else if (IS_WATCH_38)
        NSLog(@"apple watch 38mm");

Friday, October 10, 2014

Simple Animation

Simple Animation

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.3];

[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
//your code
[UIView commitAnimations];

Friday, October 3, 2014