VLCLibraryHeaderView.m 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*****************************************************************************
  2. * VLCLibraryHeaderView.m
  3. * VLC for iOS
  4. *****************************************************************************
  5. * Copyright (c) 2014 VideoLAN. All rights reserved.
  6. * $Id$
  7. *
  8. * Authors: Felix Paul Kühne <fkuehne # videolan.org>
  9. *
  10. * Refer to the COPYING file of the official project for license.
  11. *****************************************************************************/
  12. #import "VLCLibraryHeaderView.h"
  13. @interface VLCLibraryHeaderView ()
  14. {
  15. UISearchBar *_searchbar;
  16. }
  17. @end
  18. @implementation VLCLibraryHeaderView
  19. + (CGFloat)headerHeight
  20. {
  21. return 40.;
  22. }
  23. - (id)initWithFrame:(CGRect)frame
  24. {
  25. return [self initWithPredefinedFrame];
  26. }
  27. - (id)initWithPredefinedFrame
  28. {
  29. self = [super initWithFrame:CGRectMake(0., 0., 320., [VLCLibraryHeaderView headerHeight])];
  30. if (self)
  31. self.backgroundColor = [UIColor VLCDarkBackgroundColor];
  32. return self;
  33. }
  34. - (void)setSearchBar:(UISearchBar *)searchBar
  35. {
  36. if (searchBar == nil) {
  37. if (_searchbar)
  38. [_searchbar removeFromSuperview];
  39. _searchbar = nil;
  40. return;
  41. }
  42. _searchbar = searchBar;
  43. CGRect contentFrame = self.frame;
  44. _searchbar.frame = contentFrame;
  45. [self addSubview:_searchbar];
  46. }
  47. - (UISearchBar *)searchBar
  48. {
  49. return _searchbar;
  50. }
  51. @end