Trả lời

1

Chiều cao tiêu đề có thể được điều chỉnh bằng cách điều chỉnh params bố trí xem bộ sưu tập. Sau đây là mã cho cùng:

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section 
{ 
    //{top, left, bottom, right} 

    if ([[sectionHeaderArray objectAtIndex:section] boolValue]) { 
     return UIEdgeInsetsMake(10, 10, 10, 10); 
    } 

     return UIEdgeInsetsZero; 
} 
1

Đây là vấn đề bố trí, do đó câu trả lời sẽ là trong bất cứ bố trí bạn đang sử dụng cho xem bộ sưu tập. Nếu bạn đang sử dụng UICollectionViewFlowLayout thì bạn sẽ muốn đặt sectionInset. ví dụ.

self.collectionView.collectionViewLayout.sectionInset = UIEdgeInsetsZero; 
+0

Không, nó không hoạt động. –

+0

Cung cấp thêm thông tin. Bạn đang sử dụng bố cục nào? Tôi nghĩ rằng bạn cần phải điều tra vào bất kỳ bố cục nào. –

13

Bạn có thể sử dụng phương pháp để thực hiện điều này:

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout insetForSectionAtIndex:(NSInteger)section 
{ 
    //{top, left, bottom, right} 

    if ([[sectionHeaderStatusArray objectAtIndex:section] boolValue]) { 
     return UIEdgeInsetsMake(23, 19, 46, 14); 
    } 

     return UIEdgeInsetsZero; 
} 
+1

Giải pháp này hoạt động như sự quyến rũ. – salabaha

Các vấn đề liên quan