- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
最佳答案
据我所知,您的意思是说您需要显示一堆图像,并且从一个图像移动到另一个图像时,背景图像会相应改变。
样式 1:-
您可以在屏幕底部使用一个collectionView来显示缩略图,并在背景中使用一个imageView,并且在collectionView:didSelectItemAtIndexPath:
上您可以通过将其设置为值来更改您的背景图像在点击的 indexPath 处。
样式 2:-
您可以在屏幕底部使用一个“collectionView1”来显示缩略图,并在其后面使用另一个“collectionView2”。当您点击 collectionView:didSelectItemAtIndexPath:
(对于“collectionView1”)时,您可以将“collectionView2”滚动到该索引路径,这样就会产生有人正在使用以下方式滑动它的感觉:-
collectionView2.scrollToItemAtIndexPath(tappedIndexPath, atScrollPosition: .CenteredHorizontally, animated: true)
检查您是否正确设置了 UICollectionViewDelegateFlowLayout
的委托(delegate)方法。
func collectionView(collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return CGSize(width: 40, height: 40)
}
func collectionView(collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
insetForSectionAtIndex section: Int) -> UIEdgeInsets {
return sectionInsets
//returns the spacing between the cells, headers, and footers.
}
func collectionView(collectionView: UICollectionView,
layout collectionViewLayout: UICollectionViewLayout,
minimumInteritemSpacingForSectionAtIndex section: Int) -> CGFloat {
return 5.0
// spacing between items
}
func collectionView(collectionView: UICollectionView, layout
collectionViewLayout: UICollectionViewLayout,
minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
return 1.0
// spacing between lines
}
此外,不要忘记在 collectionViewCell 中为其中的 imageView 添加约束。将顶部、底部、尾部和前导约束设置为 0。您可以通过 Storyboard以编程方式设置它。
肯定能练习。删除您的对象并再次添加您的约束。清理并运行您的代码。
关于ios - 像 PhotosApp 这样的 Collectionview SubImages,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37363613/
我正在尝试向 CollectionView 水平流布局上的内容添加缩略图,例如苹果照片应用程序,如下所示。 我应该用什么来实现这个目的? 谢谢。 最佳答案 据我所知,您的意思是说您需要显示一堆图像,并
我是一名优秀的程序员,十分优秀!