The iOS framework that grows only as fast as its documentation
Common Metrics

Functions

CGFloat NIMinimumTapDimension (void)
 
CGFloat NIToolbarHeightForOrientation (UIInterfaceOrientation orientation)
 
UIViewAnimationCurve NIStatusBarAnimationCurve (void)
 
NSTimeInterval NIStatusBarAnimationDuration (void)
 
UIViewAnimationCurve NIStatusBarBoundsChangeAnimationCurve (void)
 
NSTimeInterval NIStatusBarBoundsChangeAnimationDuration (void)
 
CGFloat NIStatusBarHeight (void)
 
NSTimeInterval NIDeviceRotationDuration (BOOL isFlippingUpsideDown)
 
UIEdgeInsets NICellContentPadding (void)
 

Overview

For common system metrics.

If you work with system metrics in any way it can be a pain in the ass to figure out what the exact metrics are. Figuring out how long it takes the status bar to animate is not something you should be spending your time on. The metrics in this file are provided as a means of unifying a number of system metrics for use in your applications.

What Qualifies as a Common Metric

Common metrics are system components, such as the dimensions of a toolbar in a particular orientation or the duration of a standard animation. This is not the place to put feature-specific metrics, such as the height of a photo scrubber view.

Examples

Positioning a Toolbar

The following example updates the position and height of a toolbar when the device orientation is changing. This ensures that, in landscape mode on the iPhone, the toolbar is slightly shorter to accomodate the smaller height of the screen.

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
duration:(NSTimeInterval)duration {
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
CGRect toolbarFrame = self.toolbar.frame;
toolbarFrame.size.height = NIToolbarHeightForOrientation(toInterfaceOrientation);
toolbarFrame.origin.y = self.view.bounds.size.height - toolbarFrame.size.height;
self.toolbar.frame = toolbarFrame;
}

Function Documentation

NIMinimumTapDimension

The recommended number of points for a minimum tappable area.

CGFloat NIMinimumTapDimension:;
Discussion

Value: 44

NIToolbarHeightForOrientation

Fetch the height of a toolbar in a given orientation.

CGFloat NIToolbarHeightForOrientation:(UIInterfaceOrientation)orientation;
Discussion

On the iPhone:

  • Portrait: 44
  • Landscape: 33

On the iPad: always 44

NIStatusBarAnimationCurve

The animation curve used when changing the status bar's visibility.

UIViewAnimationCurve NIStatusBarAnimationCurve:;
Discussion

This is the curve of the animation used by -[[UIApplication sharedApplication] setStatusBarHidden:withAnimation:].

Value: UIViewAnimationCurveEaseIn

NIStatusBarAnimationDuration

The animation duration used when changing the status bar's visibility.

NSTimeInterval NIStatusBarAnimationDuration:;
Discussion

This is the duration of the animation used by -[[UIApplication sharedApplication] setStatusBarHidden:withAnimation:].

Value: 0.3 seconds

NIStatusBarBoundsChangeAnimationCurve

The animation curve used when the status bar's bounds change (when a call is received, for example).

UIViewAnimationCurve NIStatusBarBoundsChangeAnimationCurve:;
Discussion

Value: UIViewAnimationCurveEaseInOut

NIStatusBarBoundsChangeAnimationDuration

The animation duration used when the status bar's bounds change (when a call is received, for example).

NSTimeInterval NIStatusBarBoundsChangeAnimationDuration:;
Discussion

Value: 0.35 seconds

NIStatusBarHeight

Get the status bar's current height.

CGFloat NIStatusBarHeight:;
Discussion

If the status bar is hidden this will return 0.

This is generally 20 when the status bar is its normal height.

NIDeviceRotationDuration

The animation duration when the device is rotating to a new orientation.

NSTimeInterval NIDeviceRotationDuration:(BOOL)isFlippingUpsideDown;
Discussion

Value: 0.4 seconds if the device is being rotated 90 degrees. 0.8 seconds if the device is being rotated 180 degrees.

Parameters
isFlippingUpsideDownYES if the device is being flipped upside down.

NICellContentPadding

The padding around a standard cell in a table view.

UIEdgeInsets NICellContentPadding:;
Discussion

Value: 10 pixels on all sides.