Closed sz-ashik440 closed 3 years ago
Anyone does fixed this bug ?
I m facing the same issue, have you fixed this?
I found a work-around. Override sizeForItemAtIndexPath
of UICollectionViewDelegateFlowLayout
and set your custom size for you Button Bar cell size.
override func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: IndexPath) -> CGSize {
return CGSize(width: <custom_width>, Height:<custom_height>)
}
PS: to get label size, you can use this extension for String
extension String {
/// Get size for String
/// - Parameters:
/// - font: used font for string
/// - spacing: kerning value for spacing
/// - Returns: size require for text to shown
func size(with font: UIFont?, spacing: Double = 0) -> CGSize {
var attributes: [NSAttributedString.Key : Any] = font != nil ? [NSAttributedString.Key.font: font!] : [:]
attributes[.kern] = spacing
let textSize = self.size(withAttributes: attributes)
return textSize
}
}
I am trying to implement XLPagerTabStrip just like YoutubeWithLabelExampleViewController from Example project. I can configure it right but issue is width become fixed as I have to set width of
buttonBarItemSpec
.I also tried to set
settings.style.buttonBarItemsShouldFillAvailableWidth = true
andsettings.style.buttonBarItemLeftRightMargin = 0
, but still it won't resize with the label size and keep the cell size fixed(40.0).