代码改变世界

实现 QQLive HD 界面的代码

2012-03-21 13:34  java环境变量  阅读(249)  评论(0编辑  收藏  举报
实现 QQLive HD 界面的代码
总的来说QQLive HD 的主界面分成几个部分:

电视屏幕窗口

    实现方法:使用UIPageControl和UIScrollView实现。
  1. //添加一个PageControl控件,显示热点图片
  2.     m_pPageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(340, 378, 200, 50)];
  3.     if(m_pPageControl == nil)
  4.     {
  5.         return;
  6.     }
  7.     [m_pPageControl setNumberOfPages:5];
  8.     [m_pPageControl addTarget:self action:@selector(PageTurnResponse:) forControlEvents:UIControlEventValueChanged];
  9.     [self.view addSubview:m_pPageControl];
  10.     [m_pPageControl release];
  11.     
  12.     //添加一个ScrollView,用于显示图片
  13.     m_pImageScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(307, 63, 543, 330)];
  14.     if(m_pImageScrollView == nil)
  15.     {
  16.         return;
  17.     }
  18.     [m_pImageScrollView setShowsHorizontalScrollIndicator:FALSE];
  19.     [m_pImageScrollView setBackgroundColor:[UIColor clearColor]];
  20.     m_pImageScrollView.delegate = self;
  21.     [self.view addSubview:m_pImageScrollView];
  22.     [m_pImageScrollView release];
  23.     
  24.     //向ScrollView添加图片控件
  25.     for(int i = 0; i<5 ; i++)
  26.     {
  27.         UIImageView *pImageView = [[UIImageView alloc] initWithFrame:CGRectMake(i*543, 0, 543, 330)];
  28.         if(pImageView != nil)
  29.         {
  30.             [pImageView setBackgroundColor:[UIColor colorWithRed:(i+1)*0.1 green:(i+1)*0.1 blue:(i+1)*0.1 alpha:1.0]];
  31.             [m_pImageScrollView addSubview:pImageView];
  32.             [pImageView release];
  33.         }
  34.     }    
  35.     
  36.     m_pPageControl.currentPage = 0;
  37.     [m_pImageScrollView setContentSize:CGSizeMake(5*543, 330)];
复制代码
电影/电视/连续剧/综艺操作按钮

    实现方法:使用UIButton实现
  1. //添加电影/电视/电视剧/综艺按钮
  2.     UIButton *pMovieButton = [[UIButton alloc] initWithFrame:CGRectMake(100, 560, 247, 176)];
  3.     if(pMovieButton == nil)
  4.     {
  5.         return;
  6.     }
  7.     [pMovieButton setImage:[UIImage imageNamed:@"moive.png"] forState:UIControlStateNormal];
  8.     [pMovieButton setImage:[UIImage imageNamed:@"moive.png"] forState:UIControlStateHighlighted];
  9.     [pMovieButton addTarget:self action:@selector(MoiveResponse) forControlEvents:UIControlEventTouchDown];
  10.     [self.view addSubview:pMovieButton];
  11.     [pMovieButton release];
  12.     
  13.     //电视剧按钮放图层的最下面
  14.     UIButton *pClassButton = [[UIButton alloc] initWithFrame:CGRectMake(474, 505, 245, 195)];
  15.     if(pClassButton == nil)
  16.     {
  17.         return;
  18.     }
  19.     [pClassButton setImage:[UIImage imageNamed:@"class.png"] forState:UIControlStateNormal];
  20.     [pClassButton setImage:[UIImage imageNamed:@"class.png"] forState:UIControlStateHighlighted];
  21.     [pClassButton addTarget:self action:@selector(ClassResponse) forControlEvents:UIControlEventTouchDown];
  22.     [self.view addSubview:pClassButton];
  23.     [pClassButton release];
  24.         
  25.     UIButton *pTVButton = [[UIButton alloc] initWithFrame:CGRectMake(350, 514, 164, 114)];
  26.     if(pTVButton == nil)
  27.     {
  28.         return;
  29.     }
  30.     [pTVButton setImage:[UIImage imageNamed:@"tv.png"] forState:UIControlStateNormal];
  31.     [pTVButton setImage:[UIImage imageNamed:@"tv.png"] forState:UIControlStateHighlighted];
  32.     [pTVButton addTarget:self action:@selector(TVResponse) forControlEvents:UIControlEventTouchDown];
  33.     [self.view addSubview:pTVButton];
  34.     [pTVButton release];
  35.     
  36.     UIButton *pEntainmentButton = [[UIButton alloc] initWithFrame:CGRectMake(629, 560, 336, 187)];
  37.     if(pEntainmentButton == nil)
  38.     {
  39.         return;
  40.     }
  41.     [pEntainmentButton setImage:[UIImage imageNamed:@"entainment.png"] forState:UIControlStateNormal];
  42.     [pEntainmentButton setImage:[UIImage imageNamed:@"entainment.png"] forState:UIControlStateHighlighted];
  43.     [pEntainmentButton addTarget:self action:@selector(EntainmentResponse) forControlEvents:UIControlEventTouchDown];
  44.     [self.view addSubview:pEntainmentButton];
  45.     [pEntainmentButton release]
复制代码
历史记录按钮

    实现方法:使用单独的UIView检测手势操纵,使用UIImageView实现晃动的动画
  1. //添加一个历史记录晃动按钮视图
  2.     UIImageView *pHistoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 56, 67)];
  3.     if(pHistoryView == nil)
  4.     {
  5.         return;
  6.     }
  7.     
  8.     NSArray *pImageArray = [NSArray arrayWithObjects:[UIImage imageNamed:@"frame3.png"],[UIImage imageNamed:@"frame1.png"],[UIImage imageNamed:@"frame2.png"], nil];
  9.     if(pImageArray == nil)
  10.     {
  11.         return;
  12.     }
  13.     [pHistoryView setAnimationDuration:2];
  14.     [pHistoryView setAnimationRepeatCount:0];
  15.     [pHistoryView setAnimationImages:pImageArray];
  16.     [pHistoryView startAnimating];    
  17.     [self addSubview:pHistoryView];
  18.     [pHistoryView release];
复制代码
其他的节目

    没什么好解释的,就是一些UITableView加一些背景实现。其实我觉得节目列表的呈现方式不大好,不够写实。如果能够真实模拟一些碟片的实体店,和整体的风格也许更符合。