uicollectionviewflowlayout

How to alig cell to top by Flow Layout in CollectionView

99封情书 提交于 2021-02-09 11:51:46
问题 In this code I am trying to change the size of the first cell of the UICollectionView and the others with the same size but in the first row only one cell is coming out when I want two to come out: func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: if indexPath.row == 0 { return CGSize(width: collectionView.frame.width/1.5-2, height: collectionView.frame.width/1.5-2) } else { return CGSize(width: collectionView.frame.width/3.0-3, height: collectionView.frame

iOS UICollectionView Horizontal Scrolling Rectangular Layout with different size of items?

别说谁变了你拦得住时间么 提交于 2020-07-09 11:57:46
问题 iOS UICollectionView how to Create Horizontal Scrolling rectangular layout with different size of items inside. I want to create a Rectangular layout using UICollectionView like below. how can i achieve? When i scroll horizontally using CollectionView 1,2,3,4,5,6 grid will scroll together to bring 7. The Below are the dimensions of 320*480 iPhone Resolution. Updated Screen below. First 6 items have below dimensions for iPhone 5s. Item 1 Size is - (213*148) Item 2 Size is - (106*75) Item 3

UICollectionViewCell not forcing Cell Size

久未见 提交于 2020-06-23 15:35:11
问题 I am using func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: 400, height: 600) } to specify my CollectionView 's cell sizes. It works fine but as soon as I add a width constraint (UILabel.width == ContentView.width) to my UILabel inside the ContentView of the cell, the cell's width shrinks to the intrinsic width of the UILabel . I am using

UICollectionView sticky header disappears for while after inserting section when collection is overscrolled (bounce effect)

柔情痞子 提交于 2020-03-22 08:01:33
问题 I'm using UICollectionReusableView as a header of UICollectionView section. I enabled "sticky headers" with: let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout layout?.sectionHeadersPinToVisibleBounds = true I'm inserting new sections to collection with: collectionView.performBatchUpdates({ self.collectionView.insertSections(IndexSet(integersIn: collectionView.numberOfSections...viewModel.numberOfSections - 1)) }, completion: nil) If the insertion happens when

How to show three columns in a CollectionView using swift4 in all devices

杀马特。学长 韩版系。学妹 提交于 2020-01-06 05:41:10
问题 func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { if collectionView == self.collectionViewVideo { var collectionViewSize = collectionViewVideo.frame.size collectionViewSize.width = collectionViewSize.width/3.0 //Display Three elements in a row. return collectionViewSize } else { return CGSize(width: 60, height: 60) } } 回答1: You also need to take space in account. Space is your collection

How to show a collectionView like facebook upload image using swift 4?

穿精又带淫゛_ 提交于 2019-12-29 05:36:07
问题 Hello i want to show the collectionView exactly as the above image. I know that it responsible for UICollectionViewFlowLayout, but unable to do it. Help is much appreciated. Here is my code func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let yourWidth = (collectionView.bounds.width - 4) / 3.0 let yourHeight = yourWidth return CGSize(width: yourWidth, height: yourHeight) } 回答1: Your

UICollectionViewFlowLayout estimatedItemSize does not work properly with iOS12 though it works fine with iOS 11.*

♀尐吖头ヾ 提交于 2019-12-17 23:30:26
问题 For UICollectionView's dynamic height cells we use, if let layout = self.collectionViewLayout as? UICollectionViewFlowLayout { layout.estimatedItemSize = UICollectionViewFlowLayoutAutomaticSize } with the proper constraint of height and width, it works fine with iOS 11.* versions but it breaks and does not make the cells dynamic for iOS 12.0 回答1: In my case, I solved this by explicitly adding the following constraints to the cell's contentView. class Cell: UICollectionViewCell { // ...

Margins around cell like in Android GridLayout

陌路散爱 提交于 2019-12-11 16:31:22
问题 In Android it's easy to create a grid list with the next margins: I found this solution for iOS but it doesn't add margins between cell and parent view, only between cells let itemSpacing: CGFloat = 3 let itemsInOneLine: CGFloat = 2 flow.sectionInset = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) let width = UIScreen.main.bounds.size.width - itemSpacing * CGFloat(itemsInOneLine - 1) //collectionView.frame.width is the same as UIScreen.main.bounds.size.width here. flow.itemSize = CGSize

Unable to set width of UICollectionViewCell with AutoLayout

夙愿已清 提交于 2019-12-11 02:58:57
问题 I have a Collection View with cells of dynamic height (based on a possibly multiline label and a textview inside), which adapts in height perfectly when I span it over multiple lines. However, when the text is just one word or it doesn't cover the entire screen width, the cell is just as wide as needed to be, resulting in cells next to each other instead of underneath each other. Take a look at the result with different lengths of text inside the textview. However, I want the cells to be

How to use collectionview flow layout to get correct view?

戏子无情 提交于 2019-12-10 12:00:58
问题 I am using this code to get correct type but not getting the view what i want can any one tell me where am i wrong override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) screenSize = UIScreen.main.bounds screenWidth = screenSize.width screenHeight = screenSize.height videosCollectionView.delegate = self videosCollectionView.dataSource = self } func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { return 4 } func