title: How to add button to top left corner in UICollectionViewCell in iOS?
body: <p>I want to add the Button to the top left corner of the cell.I have tried but i always added inside the collection view cell but not on the cell so please tell me how can i o this?</p>
  
  <p>I have tried this.</p>
  
  <pre><code>    - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
  {
      BlogAlbumCell  *cell;
      static NSString *identifier = @"UserBlogAlbum";
      cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
      UserAlbum *user_allbum=[arr_userAlbums objectAtIndex:indexPath.row];
      cell.label_blog_name.text=user_allbum.album_name;
      [cell.image_blog_image setImageWithURL:[NSURL URLWithString:[IMAGE_BASE_URL stringByAppendingString:user_allbum.album_image]] placeholderImage:[UIImage imageNamed:@"post_placeholder.png"]];
      if([[[NSUserDefaults standardUserDefaults]valueForKey:@"longPressed"] isEqualToString:@"yes"])
      {
          NSLog(@"Inside the long press section");
          CABasicAnimation* anim = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];
          [anim setToValue:[NSNumber numberWithFloat:0.0f]];
          [anim setFromValue:[NSNumber numberWithDouble:M_PI/50]];
          [anim setDuration:0.1];
          [anim setRepeatCount:NSUIntegerMax];
          [anim setAutoreverses:YES];
          cell.layer.shouldRasterize = YES;
          [cell.layer addAnimation:anim forKey:@"SpringboardShake"];
          CGFloat delButtonSize = 30;
          UIButton *delButton = [[UIButton alloc] initWithFrame:CGRectMake(-5,-5, delButtonSize, delButtonSize)];
          delButton.backgroundColor = [UIColor clearColor];
          [delButton setImage: [UIImage imageNamed:@"cross_30.png"] forState:UIControlStateNormal];
         [delButton setBackgroundColor:[UIColor blueColor]];
          [cell addSubview:delButton];
          delButton.tag=indexPath.row;
          [delButton addTarget:self action:@selector(deleteAlbum:) forControlEvents:UIControlEventTouchUpInside];
      }
      else if ([[[NSUserDefaults standardUserDefaults]valueForKey:@"singleTap"] isEqualToString:@"yes"])
      {
          if(indexPath.row==([arr_userAlbums count]-1))
          {
              [[NSUserDefaults standardUserDefaults]setValue:@"no" forKey:@"singleTap"];
          }
          for(UIView *subview in [cell subviews])
          {
              if([subview isKindOfClass:[UIButton class]])
              {
                  [subview removeFromSuperview];
              }
  
          }
          [cell.layer removeAllAnimations];
          // _deleteButton.hidden = YES; 
           [_deleteButton removeFromSuperview];
      }
          return cell;
  }
  </code></pre>
  
  <p>But it does not add the button to the top left.</p>
  
  <p>I want like this </p>
  
  <p><a href="https://i.stack.imgur.com/cbjke.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cbjke.png" alt="enter image description here"></a></p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>This is what i am getting as of now 
  <a href="https://i.stack.imgur.com/QqPJ4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QqPJ4.png" alt="enter image description here"></a></p>