The iOS framework that grows only as fast as its documentation
NICommonMetrics.m
1 //
2 // Copyright 2011-2014 NimbusKit
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 
17 #import "NICommonMetrics.h"
18 
19 #import "NISDKAvailability.h"
20 
21 #if !defined(__has_feature) || !__has_feature(objc_arc)
22 #error "Nimbus requires ARC support."
23 #endif
24 
25 CGFloat NIMinimumTapDimension(void) {
26  return 44;
27 }
28 
29 CGFloat NIToolbarHeightForOrientation(UIInterfaceOrientation orientation) {
30  return (NIIsPad()
31  ? 44
32  : (UIInterfaceOrientationIsPortrait(orientation)
33  ? 44
34  : 33));
35 }
36 
37 UIViewAnimationCurve NIStatusBarAnimationCurve(void) {
38  return UIViewAnimationCurveEaseIn;
39 }
40 
41 NSTimeInterval NIStatusBarAnimationDuration(void) {
42  return 0.3;
43 }
44 
45 UIViewAnimationCurve NIStatusBarBoundsChangeAnimationCurve(void) {
46  return UIViewAnimationCurveEaseInOut;
47 }
48 
50  return 0.35;
51 }
52 
53 CGFloat NIStatusBarHeight(void) {
54  CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
55 
56  // We take advantage of the fact that the status bar will always be wider than it is tall
57  // in order to avoid having to check the status bar orientation.
58  CGFloat statusBarHeight = MIN(statusBarFrame.size.width, statusBarFrame.size.height);
59 
60  return statusBarHeight;
61 }
62 
63 NSTimeInterval NIDeviceRotationDuration(BOOL isFlippingUpsideDown) {
64  return isFlippingUpsideDown ? 0.8 : 0.4;
65 }
66 
67 UIEdgeInsets NICellContentPadding(void) {
68  return UIEdgeInsetsMake(10, 10, 10, 10);
69 }
CGFloat NIMinimumTapDimension(void)
The recommended number of points for a minimum tappable area.
UIViewAnimationCurve NIStatusBarAnimationCurve(void)
The animation curve used when changing the status bar's visibility.
NSTimeInterval NIDeviceRotationDuration(BOOL isFlippingUpsideDown)
The animation duration when the device is rotating to a new orientation.
CGFloat NIToolbarHeightForOrientation(UIInterfaceOrientation orientation)
Fetch the height of a toolbar in a given orientation.
CGFloat NIStatusBarHeight(void)
Get the status bar's current height.
NSTimeInterval NIStatusBarAnimationDuration(void)
The animation duration used when changing the status bar's visibility.
NSTimeInterval NIStatusBarBoundsChangeAnimationDuration(void)
The animation duration used when the status bar's bounds change (when a call is received, for example).
UIViewAnimationCurve NIStatusBarBoundsChangeAnimationCurve(void)
The animation curve used when the status bar's bounds change (when a call is received, for example).
BOOL NIIsPad(void)
Checks whether the device the app is currently running on is an iPad or not.
UIEdgeInsets NICellContentPadding(void)
The padding around a standard cell in a table view.