Grids - Styling Section Headers (Where'd that gradient come from?)


#1

I am applying custom styling to components of my grid. I have a subclass of SDataGridSectionHeaderStyle that defines font,color,backgroundColor.  I wire that in via a call to grid.defaultSectionHeaderStyle.

The font I define, size, height and similar are all used. But the backgroundColor is ignored, and instead an unwanted gradient is applied. (see picture below with custom font, height and text color).

If I dump the view hierarchy in the debugger, I see layers with Gradients applied. 

Actual Question: How do I turn off the gradients?

Here is the code I’m using as my custom style. It is a subclass of SDataGridSectionHeaderStyle.

@implementation ReportGridSectionStyle

-(id) initForAlternateRow
{
  UIColor* backgroundColor = [[RainbowSingleton sharedInstance] gridBackground];
  UIColor* textColor = [[RainbowSingleton sharedInstance] gridText];
  UIFont* font = [[FoundrySingleton sharedInstance] sidebarData];

  self = [self initWithHeight:100 withBackgroundColor:backgroundColor withHidden:NO];
  
  if (self)
  {
    self.backgroundColor = backgroundColor;
    self.textColor = textColor;
    self.font = font;
    self.height = 200;
  }
  return self;
}
@end

And here is a snippet of the view hierarchy dumped from the debugger:

| | | | <ReportGridView: 0xaca4cf0; frame = (0 70; 1024 638); layer = <CALayer: 0xaca4dc0>>
   | | | | | <UIView: 0xaca82d0; frame = (330 0; 694 638); autoresize = W+H; layer = <CALayer: 0xaca8260>>
   | | | | | | <ShinobiDataGrid: 0xda67c00; baseClass = UIScrollView; frame = (40 40; 614 558); clipsToBounds = YES; gestureRecognizers = <NSArray: 0xaca8980>; layer = <CALayer: 0xaca8700>; contentOffset: {0, 0}>
   | | | | | | | <ShinobiGrid: 0xda67200; baseClass = UIScrollView; frame = (0 0; 614 558); clipsToBounds = YES; autoresizesSubviews = NO; gestureRecognizers = <NSArray: 0xaca9040>; layer = <CALayer: 0xaca8dc0>; contentOffset: {0, 0}>
   | | | | | | | | <UIView: 0xacabd90; frame = (0 0; 612 2604); layer = <CALayer: 0xacabdf0>>
   | | | | | | | | | <UIImageView: 0xacb0820; frame = (0 0; 0 0); alpha = 0.5; userInteractionEnabled = NO; layer = <CALayer: 0xacb08b0>> - (null)
   | | | | | | | | | <SGridLayer: 0xacada20; baseClass = UIScrollView; frame = (0 0; 614 558); clipsToBounds = YES; gestureRecognizers = <NSArray: 0xacadcc0>; layer = <CALayer: 0xacadc00>; contentOffset: {0, 0; 
No Freeze>
   | | | | | | | | | | <SGridLayerContent: 0xacade90; frame = (0 0; 612 2164); autoresizesSubviews = NO; layer = <CALayer: 0xacadf00; freezeType: No Freeze>
   | | | | | | | | | | | <SGridSectionHeader: 0x9e1d4e0; baseClass = UILabel; frame = (0 1524; 612 200.5); clipsToBounds = YES; autoresize = W; layer = <CALayer: 0x9e1d4b0>>
   | | | | | | | | | | | | <GradientLayerUIView: 0x9e1d2b0; frame = (0 0; 612 200.5); clipsToBounds = YES; layer = <CAGradientLayer: 0x9e1d280>>
   | | | | | | | | | | | | | <UILabel: 0x9e1d120; frame = (26 79.25; 145 42); text = 'Honeywell'; clipsToBounds = YES; autoresize = LM+W+RM+TM+H+BM; userInteractionEnabled = NO; layer = <CALayer: 0x9e1d0f0>>

#2

(FYI, that’s just a very very zoomed in version of the header. I didn’t want to go to all the trouble of blacking out my somewhat sensitive faked up data). 


#3

Hi Cschneid,

Have you tried setting the gradient property on your style to nil? If this doesn’t work, please let us know and we’ll look into it further!

Jan

Edit: I just wanted to add a reason as to why the gradient is there. The theme is responsible for setting the defaults of a grid, since our theme is probably using a gradient, unless you specify otherwise, it will still be present.  :laughing:


#4

As far as I can tell, that’s not a property I can set on a SDataGridSectionHeaderStyle.  Here’s the header file I’m looking at:

/** An SDataGridSectionHeaderStyle object represents the style to be used for the header of a section.*/
@interface SDataGridSectionHeaderStyle : SDataGridWrapper


/** @name Initializing a header style object.*/
/** Initialises a header style object with default values.*/
- (id) init;
/** Initialises a header style with the specified parameters.*/
- (id) initWithHeight:(float) height withBackgroundColor:(UIColor *) backgroundColor;
/** Initialises a header style with the specified parameters.*/
- (id) initWithHeight:(float) height withBackgroundColor:(UIColor *) backgroundColor withHidden:(BOOL)isHidden;

/** @name Styling*/
/** This boolean property indicates whether the section header is to be shown or not.
 
 If set to `YES` then the section at sectionIndex will have no header. Default value is `NO`.*/
@property (nonatomic, assign) BOOL hidden;

/** This property represents the height that will be applied to the section header(s).*/
@property (nonatomic, assign) float height;

/** This property represents the background color that will be applied to te section header(s).*/
@property (nonatomic, retain) UIColor *backgroundColor;

/** This property represents the text color that will be applied to the section header(s). */
@property (nonatomic, retain) UIColor *textColor;

/** This property represents the font that will be applied to the section header(s).*/
@property (nonatomic, retain) UIFont *font;

@end

Where would I set the gradient property? It doesn’t seem to be a member of this style class.


#5

Hi Cschneid - can I ask what version of ShinobiGrids you are using? You can find this out by logging out the result of [myGrid getInfo].

Jan


#6
(lldb) po [self.grid getInfo]
Version: 2.0.0, released on Apr 26 2013

#7

Hi Cschneid,

The gradient property was added in one of our more recent versions of ShinobiGrids. You’ll have to update/download a new trial if you want to remove the default gradient.

Jan