Setting Cell Border Width and Paddings from Them

Operating system requirements: iOS 5.0 or later.

Mobile device: iPad.

Description

This example describes setup of table cell border width and paddings from them. After starting the example the following operations are executed:

Source Code

Executing the example requires to place the following code in the body of the executeExample method of the ViewController class (see the Creating a Simple Data Grid section):

// Get default style for table headers
NuGridCellStyle *headerStyle = [proxyDatasource gridViewGetDefaultStyleForRowHeader:[contr gridView]];
// Align text to left border
[headerStyle setTextAlignment:UITextAlignmentLeft];
// Set up text paddings from bottom and left cell borders
[headerStyle setBottomPadding: 20.0];
[headerStyle setLeftPadding:5.0];
// Get style for other table cells
NuGridCellStyle *style = [proxyDatasource gridViewGetDefaultStyle:[contr gridView]];
// Set cell border thickness
[style setBorderWidth:2];
// Set border color
[style setBorderColor:[UIColor grayColor]];
// Align text to right border
[style setTextAlignment:UITextAlignmentRight];
// Set up text paddings from top and right cell borders
[style setTopPadding:30.0];
[style setRightPadding:15.0];

After executing the example the cells that are table headers have text aligned to left border taking into account paddings from bottom and left borders. The other cells have text aligned to right border taking into account paddings from top and right borders, and new border width and color values are also set:

Remove all paddings from table cell borders and their width value by adding the following code to the example:

// Remove paddings from cell borders
[headerStyle removeBottomPadding];
[headerStyle removeLeftPadding];
[style removeTopPadding];
[style removeRightPadding];
// Remove cell border width value
[style removeBorderWidth];

After executing the example all paddings from cell borders are removed, and their width value is removed. Text alignment settings and border color settings are not changed:

See also:

Examples of Component Use