-
Notifications
You must be signed in to change notification settings - Fork 0
/
BRMacros.h
30 lines (21 loc) · 2.79 KB
/
BRMacros.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#define setFrameX(_a_, _x_) { CGRect tempframe = _a_.frame; tempframe.origin.x = _x_; _a_.frame = tempframe; }
#define setFrameY(_a_, _y_) { CGRect tempframe = _a_.frame; tempframe.origin.y = _y_; _a_.frame = tempframe; }
#define setFrameWidth(_a_, _w_) { CGRect tempframe = _a_.frame; tempframe.size.width = _w_; _a_.frame = tempframe; }
#define setFrameHeight(_a_, _h_) { CGRect tempframe = _a_.frame; tempframe.size.height = _h_; _a_.frame = tempframe; }
#define printDimensions(__X__) TVLog(@"%s : Origin:(%f, %f) Size:(%f, %f)", #__X__, __X__.frame.origin.x, __X__.frame.origin.y, __X__.frame.size.width, __X__.frame.size.height)
#define printSize(a) TVLog(@"%s : (%f, %f)", #a, a.width, a.height)
#define radiansForOrientation(_a_) (_a_ == UIInterfaceOrientationPortrait? 0 : _a_ == UIInterfaceOrientationLandscapeLeft? M_PI/2.f : _a_ == UIInterfaceOrientationLandscapeRight? -M_PI/2.f : _a_ == UIInterfaceOrientationPortraitUpsideDown? -M_PI : 0)
#define INCREMENT_NETWORK_ACTIVITY_INDICATOR() [[[UIApplication sharedApplication] delegate] performSelector:@selector(incrementNetworkActivityIndicator)]
#define DECREMENT_NETWORK_ACTIVITY_INDICATOR() [[[UIApplication sharedApplication] delegate] performSelector:@selector(decrementNetworkActivityIndicator)]
#define degreesToRadian(x) (M_PI * (x) / 180.0)
#define RGB(r,g,b) [UIColor colorWithRed:(float)r/0xff green:(float)g/0xff blue:(float)b/0xff alpha:1.0]
#define CGRectShrink(_rect_, _padding_) CGRectMake(_rect_.origin.x+_padding_, _rect_.origin.y+_padding_, _rect_.size.width-_padding_*2, _rect_.size.height-_padding_*2);
#define CGRectScale(_rect_, _scale_) CGRectMake(_rect_.origin.x+(_rect_.size.width-(_rect_.size.width*_scale_))/2.f, _rect_.origin.y+(_rect_.size.height-(_rect_.size.height*_scale_))/2.f, _rect_.size.width*_scale_, _rect_.size.height*_scale_);
#define retina ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] && [[UIScreen mainScreen] scale] == 2)
#define ipad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define iphone (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define roundFrame(__a__) __a__.frame = CGRectMake((int)__a__.frame.origin.x, (int)__a__.frame.origin.y, (int)__a__.frame.size.width, (int)__a__.frame.size.height)
#define roundRect(__a__) __a__ = CGRectMake((int)__a__.origin.x, (int)__a__.origin.y, (int)__a__.size.width, (int)__a__.size.height)
#define setCenterX(__view__, __x__) { __view__.center = CGPointMake(__x__, __view__.center.y); }
#define setCenterY(__view__, __y__) { __view__.center = CGPointMake(__view__.center.x, __y__); }
#define centerView(__viewA__) { __viewA__.frame = CGRectMake(__viewA__.superview.frame.size.width/2.f - __viewA__.frame.size.width/2.f, __viewA__.superview.frame.size.height/2.f - __viewA__.frame.size.height/2.f, __viewA__.frame.size.width, __viewA__.frame.size.height); }