title: set Dynamic width and height of collection view cell
body: <p>Actually i want to set button dynamically and title of button appear Dynamic i have try this and got width of Dynamic content but am not setting cell width and height. </p>
  
  <pre><code>- (void)viewDidLoad {
      [super viewDidLoad];
  
      ContentArray = [[NSMutableArray alloc]init];
  
      self.collectionview.delegate = self;
      self.collectionview.dataSource =self;
      self.collectionview.backgroundColor = [UIColor clearColor];
  
  
      [ContentArray addObject:@"Planning"];
      [ContentArray addObject:@"Resources"];
      [ContentArray addObject:@"Human Resources"];
      [ContentArray addObject:@"Agriculture"];
      [ContentArray addObject:@"Resources management"];
  
  
  }
  
  - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
      {
          return ContentArray.count;
      }
  
  
      - (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
      {
  
          CollectionViewCell * Cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CollectionViewCell"forIndexPath:indexPath];
  
          [Cell.button setTitle:[ContentArray objectAtIndex:indexPath.row] forState:UIControlStateNormal];
  
          return Cell;
      }
  
  
  - (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath
      {
  
  
          CGRect rect = [[ContentArray objectAtIndex:indexPath.row ] boundingRectWithSize:CGSizeMake(HUGE_VALF, 50) options:NSStringDrawingUsesFontLeading attributes:nil context:nil] ;
  
  
          return CGSizeMake(rect.size.width, 50);
      }
  </code></pre>
  
  <p>and output is like this </p>
  
  <p><img src="https://i.stack.imgur.com/g7183m.png" alt="OUTPUT look like this when i used this code"> </p>
  
  <p>This is perfect i think if i make cell dynamic width and height, so please guide me through this.</p>