Advertisement
kencoder

Buy button

Jun 16th, 2014
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  2. {
  3.     static NSString *CellIdentifier = @"MusicCell";
  4.     MusicCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
  5.    
  6.     NSUInteger currentPage = _pageControl.currentPage;
  7.    
  8.    
  9.     if ([_albumsWithTracks count]) {
  10.      
  11.        
  12.         if (currentPage == -1 ) {
  13.             currentPage = 0;
  14.         }
  15.        
  16.         Album *album = (Album *)_albumsWithTracks[currentPage];
  17.         NSArray *tracks = album.tracks;
  18.         cell.songTitle.text = [tracks[indexPath.row] objectForKey:ALBUM_TRACK_TITLE];
  19.         NSString *type = [tracks[indexPath.row] objectForKey:@"type"];
  20.        
  21.             if ([type isEqualToString:@"buy"]) {
  22.                
  23.                 buyButton = [[UIButton alloc] initWithFrame:CGRectMake(254, 12, 50, 25)];
  24.                
  25.                 [buyButton setTitle:@"Buy" forState:UIControlStateNormal];
  26.                 [buyButton.titleLabel setFont:[UIFont systemFontOfSize:12.0f]];
  27.                 [buyButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
  28.                 [[buyButton layer] setBorderColor:[UIColor blackColor].CGColor];
  29.                 [[buyButton layer] setBorderWidth:0.5f];
  30.                 [cell addSubview:buyButton];
  31.             }
  32.        
  33.     }
  34.  
  35.     return cell;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement