Operating system requirements: iOS 5.0 or later.
Mobile device: iPad.
This example describes implementation of merging of two styles. After starting the example the following operations are executed:
A style with empty settings is created.
A style with default settings is created.
Style name is set and removed.
Text font parameters are set and removed.
Text color is set and removed.
Table cell border color is set.
Underlined text style is set and removed.
text alignment by center is set and removed.
Table cell background is set and removed.
Settings of both style are merged.
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):
// Create two default styles NuGridCellStyle *firstStyle = [NuGridCellStyle deafultStyle]; // Set the first style name [firstStyle setStyleName:@"This is the first style"]; NuGridCellStyle *secondStyle = [NuGridCellStyle emptyStyle]; // Set the second style name [secondStyle setStyleName:@"This is the second style"]; // Set text font parameters [secondStyle setFont:[UIFont fontWithName:@"Courier New" size:20]]; // Set text font for the second style [secondStyle setTextColor:[UIColor blueColor]]; // Set color for table cell borders [secondStyle setBorderColor:[UIColor orangeColor]]; // Set underlined text style for the second style [secondStyle setUnderline:YES]; // Set text alignment by cell center for the second style [secondStyle setTextAlignment: UITextAlignmentCenter]; // Set table cell background [secondStyle setBackgroundColor:[UIColor colorWithRed:(0.97f) green:0.93f blue:0.57f alpha:1]]; // Merge settings of both styles [firstStyle mergeWith:secondStyle]; // Apply the first style NuGridTheme *theme = [proxyDatasource gridViewTheme:[contr gridView]]; [theme setDefaultStyle:firstStyle]; [proxyDatasource gridView:[contr gridView] setTheme:theme];
After executing the example two styles are determined - with empty settings and with default settings. Names are set for both styles, the second style has the following settings: font parameters and text color, alignment by center, underlined text style, yellow background and orange table cell border. The second style settings are merged with the first style settings:
Then remove the determined settings by adding the following code strings to the example:
// Remove text font parameters [firstStyle removeFont]; // Remove whether text is underlined [secondStyle removeUnderline]; // Remove text alignment [secondStyle removeTextAlignment]; // Remove cell background color [firstStyle removeBackgroundColor]; // Get the first style description NSLog(@"First style description: %@", [firstStyle styleName]); // Remove style name [firstStyle removeStyleName]; NSLog(@"Style description after removal: %@", [firstStyle styleName]);
After executing the example style name, text font parameters, alignment and font style settings, cell background color are removed:
The development environment console displays style name before and after removal of the corresponding property value:
First style description: This is the second style
Style description after property value removal: (null)
Then again set yellow background for cells and remove text color:
// Set table cell background [firstStyle setBackgroundColor:[UIColor colorWithRed:(0.97f) green:0.93f blue:0.57f alpha:1]]; // Remove text color [firstStyle removeTextColor];
After executing the example the background is filled with yellow color, and text is not displayed in table cells:
See also: