IOS high imitation storm video player app source code

IOS high imitation storm video player app source code

Source code introduction: This is a demo modeled after Baofeng Video Player. Because the project requires it, I improved it a little bit. The functions include side sliding, scrolling navigation bar, tableView, and highly customized collectionView. I hope it can help code friends in need.

Source code effect:

Source code snippet:

  1. - ( void )viewDidLoad
  2. {
  3. self.view.backgroundColor = [UIColor whiteColor];
  4. UIView *statusBarView = [[UIImageView alloc] initWithFrame:CGRectMake(0.f, 0.f, self.view.frame.size.width, 0.f)];
  5. if (isIos7 >= 7 && __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1)
  6. {
  7. statusBarView.frame = CGRectMake(statusBarView.frame.origin.x, statusBarView.frame.origin.y, statusBarView.frame.size.width, 20.f);
  8. statusBarView.backgroundColor = [UIColor clearColor];
  9. ((UIImageView *)statusBarView).backgroundColor = RGBA(33.f,125.f,194.f,1);
  10. [self.view addSubview:statusBarView];
  11. }
  12.       
  13. //Navigation bar  
  14. _navView = [[UIImageView alloc] initWithFrame:CGRectMake(0.f, StatusbarSize, self.view.frame.size.width, 50.f)];
  15. ((UIImageView *)_navView).backgroundColor = RGBA(33.f,125.f,194.f,1);
  16. [self.view insertSubview:_navView belowSubview:statusBarView];
  17. _navView.userInteractionEnabled = YES;
  18.       
  19. //Navigation bar icon  
  20. [self setNavbtn];
  21.       
  22. //Scroll the navigation bar  
  23. _topNaviV = [[UIView alloc] initWithFrame:CGRectMake(0, _navView.frame.size.height + _navView.frame.origin.y, self.view.frame.size.width, MENU_HEIGHT)];
  24. _topNaviV.backgroundColor = RGBA(33.f,125.f,194.f,1);
  25. [self.view addSubview:_topNaviV];
  26.       
  27. //Scroll the page  
  28. _scrollV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, _topNaviV.frame.origin.y + _topNaviV.frame.size.height, self.view.frame.size.width, self.view.frame.size.height - _topNaviV.frame.origin.y - _topNaviV.frame.size.height)];
  29. _scrollV.tag = _scrollVTag;
  30. [_scrollV setPagingEnabled:YES];
  31. [_scrollV setShowsHorizontalScrollIndicator:NO];
  32. [self.view insertSubview:_scrollV belowSubview:_navView];
  33. _scrollV.delegate = self;
  34. [_scrollV.panGestureRecognizer addTarget:self action:@selector(scrollHandlePan:)];
  35.       
  36. //Select the pop-up view  
  37. _selectTabV = [[UIView alloc] initWithFrame:CGRectMake(0, _scrollV.frame.origin.y - _scrollV.frame.size.height, _scrollV.frame.size.width, _scrollV.frame.size.height)];
  38. [_selectTabV setBackgroundColor:RGBA(255.f, 209.f, 56.f, 1)];
  39. [_selectTabV setHidden:YES];
  40. [self.view insertSubview:_selectTabV belowSubview:_navView];
  41.       
  42. //Create a scroll bar menu  
  43. [self createScrollBtns];
  44.       
  45. }
  46.   
  47. //Create the main navigation menu  
  48. -( void )setNavbtn{
  49.   
  50. UIButton *MenuBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  51. [MenuBtn setFrame:CGRectMake(15, 8, 20, 20)];
  52. [MenuBtn setBackgroundImage:[UIImage imageNamed:@ "icon_list" ] forState:UIControlStateNormal];
  53. [MenuBtn addTarget:self action:@selector(leftAction:) forControlEvents:UIControlEventTouchUpInside];
  54. MenuBtn.showsTouchWhenHighlighted = YES;
  55. [_navView addSubview:MenuBtn];
  56.       
  57. for ( int i = 0; i < 4; i++) {
  58. UIButton *NavBtn = [UIButton buttonWithType:UIButtonTypeCustom];
  59. [NavBtn setFrame:CGRectMake(170 + i*40, 8, 20, 20)];
  60. NSString *NavBtn_backimg = [NSString stringWithFormat:@ "slide_menu_%d@2x" ,i+1];
  61. [NavBtn setBackgroundImage:[UIImage imageNamed:NavBtn_backimg] forState:UIControlStateNormal];
  62. [NavBtn addTarget:self action:@selector(NavbtnAction:) forControlEvents:UIControlEventTouchUpInside];
  63. NavBtn.tag = MENU_NAVBUTTON_TAG + i;
  64. [_navView addSubview:NavBtn];
  65. }
  66. }
  67.   
  68. //Create a scroll menu  
  69. - ( void )createScrollBtns
  70. {
  71. float btnW = 40;
  72. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  73. [btn setFrame:CGRectMake(_topNaviV.frame.size.width - btnW, 0, btnW, 30)];
  74. [btn setBackgroundImage:[UIImage imageNamed:@ "nav_more" ] forState:UIControlStateNormal];
  75. [_topNaviV addSubview:btn];
  76. [btn addTarget:self action:@selector(showSelectView:) forControlEvents:UIControlEventTouchUpInside];
  77.           
  78. _scrollDataSource = [NSMutableArray arrayWithObjects:@ "recommendation" , @ "movie" , @ "TV series" , @ "cartoon" , @ "variety show" , @ "sports" , @ "entertainment" , @ "news" , nil];
  79.       
  80. _navScrollV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width - btnW, MENU_HEIGHT)];
  81. _navScrollV.tag = _navScrollVTag;
  82. [_navScrollV setShowsHorizontalScrollIndicator:NO];
  83. for ( int i = 0; i < [_scrollDataSource count]; i++)
  84. {
  85. UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
  86. [btn setFrame:CGRectMake(MENU_BUTTON_WIDTH * i, -5, MENU_BUTTON_WIDTH, MENU_HEIGHT)];
  87. [btn setTitle:[_scrollDataSource objectAtIndex:i] forState:UIControlStateNormal];
  88. [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
  89. btn.tag = i + 1;
  90. [btn addTarget:self action:@selector(ScrolBtnActionbtn:) forControlEvents:UIControlEventTouchUpInside];
  91. btn.showsTouchWhenHighlighted = YES;
  92. [_navScrollV addSubview:btn];
  93. }
  94. [_navScrollV setContentSize:CGSizeMake(MENU_BUTTON_WIDTH * [_scrollDataSource count], MENU_HEIGHT)];
  95. [_topNaviV addSubview:_navScrollV];
  96.       
  97. //Scroll bar bottom scroll bar  
  98. _navBgV = [[UIView alloc] initWithFrame:CGRectMake(0, MENU_HEIGHT - 5, MENU_BUTTON_WIDTH, 5)];
  99. [_navBgV setBackgroundColor:[UIColor redColor]];
  100. [_navScrollV addSubview:_navBgV];
  101. [self addView2Page:_scrollV count:[_scrollDataSource count] frame:CGRectZero];
  102. }
  103.   
  104. //Initialize the view content to display the content of the currently selected scroll btn  
  105. - ( void )addView2Page:(UIScrollView *)scrollV count:(NSUInteger)pageCount frame:(CGRect)frame
  106. {
  107. for ( int i = 0; i < pageCount; i++)
  108. {
  109. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(scrollV.frame.size.width * i, 0, scrollV.frame.size.width, scrollV.frame.size.height)];
  110. view.tag = i + 1;
  111.           
  112. //Initialize collectionViews video view  
  113. [self creatScrollSubViewsInViews:view];
  114.           
  115. [scrollV addSubview:view];
  116. }
  117. [scrollV setContentSize:CGSizeMake(scrollV.frame.size.width * pageCount, scrollV.frame.size.height)];
  118. }

Download address: http://download..com/data/2089516

<<:  Share a very good news client (based on Baidu data)

>>:  Select pictures by imitating WeChat Moments

Recommend

Technology News | Japan uses supercomputer to predict six quark particles

【Today’s cover】 With the arrival of winter, Tangg...

Tencent technical tips! How to make a terrifying HTML5 page

The whole text is full of valuable information an...

He shot a gorilla and brought it back to life

In 1896, in what is now Somalia, Carl Akeley fire...

Chen Chao: 60 Inventions That Influenced the World

Chen Chao · "60 Great Inventions That Influe...

Don’t lose weight too much! At critical moments, fat can save lives!

Review expert: Peng Guoqiu, deputy chief physicia...

I gained 180,000 followers in 3 days. How did I plan the free giveaway?

Editor's note: When running an event , giving...

Beijing Winter Olympics: How does China produce the world's "fastest" ice?

Mixed Knowledge Specially designed to cure confus...

Ghosn may no longer serve as Renault CEO, successor will be found from within

According to foreign media reports, Carlos Ghosn,...