Closed vietnguyen09 closed 5 years ago
You need to add space on top of Another Card text card ?
I need this whole card section has space between my large title navigation bar header, you can see them stick together.
this view would be embedded inside the collection view. Get the flow layout of it and set section inset space.
let layout = self.collectionview.collectionviewFlowlayout as? UIcollectionViewflowlayout layout.sectionInset = UIEdgeInset(top:10, left:10, bottom:10, right :10)
No this is not collectionview
, here is my temporary solution.
Firstly, I create a Swift file called SpacerCardParts.swift
which are use TransparentCardTrait
and NoTopBottomMarginsCardTrait
import Foundation
import CardParts
class SpacerCardParts: CardPartsViewController, TransparentCardTrait, NoTopBottomMarginsCardTrait {
}
Then in my ViewController.swift
I added this SpacerCardParts
let cards: [CardPartsViewController] = [
SpacerCardParts(),
DateSelectController()
]
loadCards(cards: cards)
If there is any better way please let me know.
Thanks
Try below code in SpaceCardParts
class SpacerCardParts: CardPartsViewController, TransparentCardTrait, NoTopBottomMarginsCardTrait {
override func viewDidLoad() {
super.viewDidLoad()
let spacerView =CardPartSpacerView(height:20)
spacerView.margins = UIEdgeInsets(top:10, left:0, bottom:10, right:0)
setupCardParts(spacerView)
}
}
or alternatively u can add below code inside viewDidLoad()
of ViewController.swift
, assuming
class ViewController:CardsViewController {
override func viewLoad() {
let layout = self.collectionview.collectionViewFlowLayout as? UICollectionViewfFlowLayout
layout.sectionInset = UIEdgeInset(top:10, left:10, bottom:10, right :10)
}
}
as CardsViewController embeds CollectionView.
Unfortunately, it does not work somehow.
Correct the spelling of uicollectionviewflowlayout
Thanks, correct syntax for Swift 4 - 5 is
let layout = self.collectionView.collectionViewLayout as? UICollectionViewFlowLayout
layout!.sectionInset = UIEdgeInsets(top:100, left:10, bottom:10, right :10)
It works like a charm, thanks @badrinathvm
You welcome. Closing the issue as it’s working as expected.
Hi guys,
Could anyone help me to add an extra space on top of the CardParts? Here is what I dealing with now.
I use
CardPartSpacerView
but is not working.Any way to fix this?