Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Customizing the header can be done to provide more information to the users.

  1. Create a that implments implements BABFeedHeaderView.

    1. Configure the view through the interface builder or code.

    2. Override desiredHeight to specify the height of the desired headerView.

      Code Block
      languageobjective-c
      // Objective-C
      @interface CustomHeaderView: BABFeedHeaderView
      @end
      
      @implementation CustomHeaderView
      
      + (CGFloat)desiredHeight {
        return 115.0f;
      }
      
      - (void)loadFromNib {
        UIView *header = [[UINib nibWithNibName:@"CustomHeaderView" bundle:[NSBundle bundleForClass:[CustomHeaderView class]]] instantiateWithOwner:self options:nil][0];
        [self addSubview:header];
      }
      
      @end


      Code Block
      languageswift
      // Swift
      class CustomHeaderView: BABFeedHeaderView {
        override class func desiredHeight() -> CGFloat {
          return 115.0f
        }
      
        func loadFromNib() {
          let headerView = Bundle(for: type(of: self)).loadNibNamed("CustomHeaderView", owner: self, options: 
      nil)?.first as! UIView
          addSubview(headerView)
        }
      }

  2. Specify the headerViewClass via BABFeedConfig.

    Code Block
    languageobjective-c
    // Objective-C
    BABFeedConfig *config = [[BABFeedConfig alloc] initWithUnitId:YOUR_FEED_UNIT_ID];
    ...
    config.headerViewClass = [CustomHeaderView class];


    Code Block
    languageswift
    // Swift
    let config = BABFeedConfig(unitId: YOUR_FEED_UNIT_ID)
    ...
    config.headerViewClass = CustomHeaderView.self

...