Приветствую, что можно добавить эффект обтекания в виде uicollection в горизонтальном макете. Если возможно, любезно скажите мне, как реализовать эффект.UIcollection view cover cover flow
1
A
ответ
1
Да, это возможно, вам необходимо реализовать свой пользовательский UICollectionViewFlowLayout.
сделать пользовательский класс, который наследует UICollectionViewFlowLayout
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)newBounds {
return YES; }
- (UICollectionViewScrollDirection)scrollDirection {
return UICollectionViewScrollDirectionVertical; }
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
UICollectionView *collectionView = [self collectionView];
UIEdgeInsets insets = [collectionView contentInset];
CGPoint offset = [collectionView contentOffset];
CGFloat minY = -insets.top;
NSArray *attributes = [super layoutAttributesForElementsInRect:rect];
// minY is Point where we implement this cover flow.
if (offset.y < minY) {
// Figure out how much we've pulled down
CGFloat deltaY = fabsf(offset.y - minY);
for (UICollectionViewLayoutAttributes *attrs in attributes) {
// Locate the header attributes
NSString *kind = [attrs representedElementKind];
if (kind == UICollectionElementKindSectionHeader) {
// This is header's height and y based on how much the user has scrolled down.
CGSize headerSize = [self headerReferenceSize];
CGRect headerRect = [attrs frame];
headerRect.size.height = MAX(minY, headerSize.height + deltaY);
headerRect.origin.y = headerRect.origin.y - deltaY;
[attrs setFrame:headerRect];
break;
}
}
}
return attributes; }
Теперь в вашем классе, где вы размещаете UICollectionView
CustomCoverFlowHeaderCollectionViewLayout *flow; flow = [[CustomCoverFlowHeaderCollectionViewLayout alloc] init]; [stretchyLayout setHeaderReferenceSize:CGSizeMake(320.0, 160.0)]; // Set our custom layout [collectionView setCollectionViewLayout: flow]; [collectionView setAlwaysBounceVertical:YES]; [collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader
withReuseIdentifier:@"myCoverCollectionView"];
Вы почти закончили
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
viewForSupplementaryElementOfKind:(NSString *)kind
atIndexPath:(NSIndexPath *)indexPath {
if (!header) {
header = [collectionView dequeueReusableSupplementaryViewOfKind:kind
withReuseIdentifier:@"myCoverCollectionView" forIndexPath:indexPath];
CGRect bounds;
bounds = [header bounds];
UIImageView *imageView;
imageView = [[UIImageView alloc] initWithFrame:bounds];
[imageView setImage:[UIImage imageNamed:@"background"]];
[imageView setContentMode:UIViewContentModeScaleAspectFill];
[imageView setClipsToBounds:YES];
[imageView setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
[header addSubview:imageView];
}
return header; }
1
Here хороший проект, основанный на UICollectionView для вас.
Смежные вопросы
- 1. iPhone - Cover Flow
- 2. Cover Flow Advice
- 3. Android Cover Flow
- 4. Facebook Cover Cover URL
- 5. .NET Cover Cover Tool Tool
- 6. UIView border cover sub-view?
- 7. Как создать эффект Cover Flow в андроида
- 8. Android Cover Flow с изображением эффекта тени
- 9. # e5004f + cover = # 720027, x + cover = # e5004f, x =?
- 10. Это ошибка в Devel :: Cover code cover?
- 11. Cover Effect CSS
- 12. UICollection View Flow Layout Вертикальное выравнивание
- 13. CollapsingToolbarLayout info cover title
- 14. Как вы реализовали Cover Flow ui в веб-браузере?
- 15. Android Cover Flow галерея и удалите пробел между
- 16. Эффект Apple Cover-flow с использованием jQuery или другой библиотеки?
- 17. Cover Flow имеет вид с помощью пейджера андроида
- 18. Создание эффекта Cover Flow, как Apple с jQuery
- 19. GtkButton cover by GtkDrawingArea
- 20. Rails i18n cover
- 21. css background cover images
- 22. Grails 3 Cover Coverage
- 23. biclique cover implementation
- 24. Set Cover Reduction
- 25. i3bar cover Photoshop меню
- 26. Heading cover the body
- 27. UIViewAnimationOption Enum Cover Vertical
- 28. UITableview cover button
- 29. Devel :: Cover HTML output
- 30. JasperReports: Cover page
Убедитесь, что вы используете блоки кода для форматирования блоков без кодов. Просто выделите код и нажмите CMD-K – Fogmeister