ios高仿暴风视频播放器app源码

移动开发
这是一款仿照暴风影音做的demo,因为项目需要,所以顺便把他完善一点,功能有侧滑,滚动导航栏,tableView ,collectionView的高度定制,希望能帮助到有需求的码友。

源码简介:这是一款仿照暴风影音做的demo,因为项目需要,所以顺便把他完善一点,功能有侧滑,滚动导航栏,tableView ,collectionView的高度定制,希望能帮助到有需求的码友。

源码效果:

源码片段:

  1. - (void)viewDidLoad 
  2.     self.view.backgroundColor = [UIColor whiteColor]; 
  3.     UIView *statusBarView = [[UIImageView alloc] initWithFrame:CGRectMake(0.f, 0.f, self.view.frame.size.width, 0.f)]; 
  4.     if (isIos7 >= 7 && __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1) 
  5.     { 
  6.         statusBarView.frame = CGRectMake(statusBarView.frame.origin.x, statusBarView.frame.origin.y, statusBarView.frame.size.width, 20.f); 
  7.         statusBarView.backgroundColor = [UIColor clearColor]; 
  8.         ((UIImageView *)statusBarView).backgroundColor = RGBA(33.f,125.f,194.f,1); 
  9.         [self.view addSubview:statusBarView]; 
  10.     } 
  11.       
  12.     //导航栏 
  13.     _navView = [[UIImageView alloc] initWithFrame:CGRectMake(0.f, StatusbarSize, self.view.frame.size.width, 50.f)]; 
  14.     ((UIImageView *)_navView).backgroundColor = RGBA(33.f,125.f,194.f,1); 
  15.     [self.view insertSubview:_navView belowSubview:statusBarView]; 
  16.     _navView.userInteractionEnabled = YES; 
  17.       
  18.     //导航栏图标 
  19.     [self setNavbtn]; 
  20.       
  21.     //滚动导航栏 
  22.     _topNaviV = [[UIView alloc] initWithFrame:CGRectMake(0, _navView.frame.size.height + _navView.frame.origin.y, self.view.frame.size.width, MENU_HEIGHT)]; 
  23.     _topNaviV.backgroundColor = RGBA(33.f,125.f,194.f,1); 
  24.     [self.view addSubview:_topNaviV]; 
  25.       
  26.     //滚动页面 
  27.     _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)]; 
  28.     _scrollV.tag = _scrollVTag; 
  29.     [_scrollV setPagingEnabled:YES]; 
  30.     [_scrollV setShowsHorizontalScrollIndicator:NO]; 
  31.     [self.view insertSubview:_scrollV belowSubview:_navView]; 
  32.     _scrollV.delegate = self; 
  33.     [_scrollV.panGestureRecognizer addTarget:self action:@selector(scrollHandlePan:)]; 
  34.       
  35.     //选择弹出的view 
  36.     _selectTabV = [[UIView alloc] initWithFrame:CGRectMake(0, _scrollV.frame.origin.y - _scrollV.frame.size.height, _scrollV.frame.size.width, _scrollV.frame.size.height)]; 
  37.     [_selectTabV setBackgroundColor:RGBA(255.f, 209.f, 56.f, 1)]; 
  38.     [_selectTabV setHidden:YES]; 
  39.     [self.view insertSubview:_selectTabV belowSubview:_navView]; 
  40.       
  41.     //创建滚动条菜单 
  42.     [self createScrollBtns]; 
  43.       
  44.   
  45. //创建主导航菜单 
  46. -(void)setNavbtn{ 
  47.   
  48.     UIButton *MenuBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 
  49.     [MenuBtn setFrame:CGRectMake(15, 8, 20, 20)]; 
  50.     [MenuBtn setBackgroundImage:[UIImage imageNamed:@"icon_list"] forState:UIControlStateNormal]; 
  51.     [MenuBtn addTarget:self action:@selector(leftAction:) forControlEvents:UIControlEventTouchUpInside]; 
  52.     MenuBtn.showsTouchWhenHighlighted = YES; 
  53.     [_navView addSubview:MenuBtn]; 
  54.       
  55.     for (int i = 0; i < 4; i++) { 
  56.         UIButton *NavBtn = [UIButton buttonWithType:UIButtonTypeCustom]; 
  57.         [NavBtn setFrame:CGRectMake(170 + i*40, 8 , 20, 20)]; 
  58.         NSString *NavBtn_backimg = [NSString stringWithFormat:@"slide_menu_%d@2x",i+1]; 
  59.         [NavBtn setBackgroundImage:[UIImage imageNamed:NavBtn_backimg] forState:UIControlStateNormal]; 
  60.         [NavBtn addTarget:self action:@selector(NavbtnAction:) forControlEvents:UIControlEventTouchUpInside]; 
  61.         NavBtn.tag = MENU_NAVBUTTON_TAG + i; 
  62.         [_navView addSubview:NavBtn]; 
  63.     } 
  64.   
  65. //创建scroll 滚动菜单 
  66. - (void)createScrollBtns 
  67.     float btnW = 40; 
  68.     UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 
  69.     [btn setFrame:CGRectMake(_topNaviV.frame.size.width - btnW, 0, btnW, 30)]; 
  70.     [btn setBackgroundImage:[UIImage imageNamed:@"nav_more"] forState:UIControlStateNormal]; 
  71.     [_topNaviV addSubview:btn]; 
  72.     [btn addTarget:self action:@selector(showSelectView:) forControlEvents:UIControlEventTouchUpInside]; 
  73.           
  74.     _scrollDataSource = [NSMutableArray arrayWithObjects:@"推荐", @"电影", @"电视剧", @"卡通", @"综艺", @"体育", @"娱乐", @"新闻", nil]; 
  75.       
  76.     _navScrollV = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width - btnW, MENU_HEIGHT)]; 
  77.     _navScrollV.tag = _navScrollVTag; 
  78.     [_navScrollV setShowsHorizontalScrollIndicator:NO]; 
  79.     for (int i = 0; i < [_scrollDataSource count]; i++) 
  80.     { 
  81.         UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom]; 
  82.         [btn setFrame:CGRectMake(MENU_BUTTON_WIDTH * i, -5, MENU_BUTTON_WIDTH, MENU_HEIGHT)]; 
  83.         [btn setTitle:[_scrollDataSource objectAtIndex:i] forState:UIControlStateNormal]; 
  84.         [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; 
  85.         btn.tag = i + 1; 
  86.         [btn addTarget:self action:@selector(ScrolBtnActionbtn:) forControlEvents:UIControlEventTouchUpInside]; 
  87.         btn.showsTouchWhenHighlighted = YES; 
  88.         [_navScrollV addSubview:btn]; 
  89.     } 
  90.     [_navScrollV setContentSize:CGSizeMake(MENU_BUTTON_WIDTH * [_scrollDataSource count], MENU_HEIGHT)]; 
  91.     [_topNaviV addSubview:_navScrollV]; 
  92.       
  93.     //滚动栏底部 滚动条 
  94.     _navBgV = [[UIView alloc] initWithFrame:CGRectMake(0, MENU_HEIGHT - 5, MENU_BUTTON_WIDTH, 5)]; 
  95.     [_navBgV setBackgroundColor:[UIColor redColor]]; 
  96.     [_navScrollV addSubview:_navBgV]; 
  97.     [self addView2Page:_scrollV count:[_scrollDataSource count] frame:CGRectZero]; 
  98.   
  99. //初始化视图内容  显示当前选中scroll的btn要显示的内容 
  100. - (void)addView2Page:(UIScrollView *)scrollV count:(NSUInteger)pageCount frame:(CGRect)frame 
  101.     for (int i = 0; i < pageCount; i++) 
  102.     { 
  103.         UIView *view = [[UIView alloc] initWithFrame:CGRectMake(scrollV.frame.size.width * i, 0, scrollV.frame.size.width, scrollV.frame.size.height)]; 
  104.         view.tag = i + 1; 
  105.           
  106.         //初始化collectionViews 视频视图 
  107.         [self creatScrollSubViewsInViews:view]; 
  108.           
  109.         [scrollV addSubview:view]; 
  110.     } 
  111.     [scrollV setContentSize:CGSizeMake(scrollV.frame.size.width * pageCount, scrollV.frame.size.height)]; 

下载地址:http://down.51cto.com/data/2089516

责任编辑:倪明 来源: devstore
相关推荐

2015-01-22 15:44:55

Android源码音乐播放器

2023-03-29 09:32:15

视频播放器应用鸿蒙

2023-03-28 09:38:34

开发应用鸿蒙

2023-03-28 09:44:02

开发应用鸿蒙

2023-03-29 09:37:49

视频播放器应用鸿蒙

2022-06-21 14:41:38

播放器适配西瓜视频

2009-06-01 14:05:14

2022-08-16 17:37:06

视频播放器鸿蒙

2011-07-20 16:21:20

iPhone 视频 播放器

2015-05-21 15:25:42

VLC播放器

2014-12-31 16:52:53

音乐播放器源码

2021-10-19 14:27:07

鸿蒙HarmonyOS应用

2021-10-21 16:00:07

鸿蒙HarmonyOS应用

2022-11-12 08:26:04

VLC视频播放器裁剪视频

2018-05-25 14:37:58

2023-03-06 16:20:08

视频播放器VLC

2023-08-26 19:07:40

VLC旋转视频

2011-05-09 15:17:24

亚马逊iOS苹果

2011-06-13 09:33:04

2011-08-09 14:42:07

iPhonePCM播放器
点赞
收藏

51CTO技术栈公众号