FSPagerView
FSPagerView copied to clipboard
How to increase height of left and right item in linear case ?
I need the same!, someone who can help? Thx!
any help?
Subclass FSPagerViewTransformer
and override func applyTransform(to attributes: FSPagerViewLayoutAttributes)
worked for me.
class NoVerticalScalePagerViewTransformer: FSPagerViewTransformer {
override func applyTransform(to attributes: FSPagerViewLayoutAttributes) {
guard let pagerView = self.pagerView else {
return
}
let position = attributes.position
let scrollDirection = pagerView.scrollDirection
let itemSpacing = (scrollDirection == .horizontal ? attributes.bounds.width : attributes.bounds.height) + self.proposedInteritemSpacing()
if self.type == .linear {
guard scrollDirection == .horizontal else {
// This type doesn't support vertical mode
return
}
let scale = max(1 - (1-self.minimumScale) * abs(position), self.minimumScale)
// let transform = CGAffineTransform(scaleX: scale, y: scale)
// **Modify here**
let transform = CGAffineTransform(scaleX: scale, y: 1.0)
attributes.transform = transform
let alpha = (self.minimumAlpha + (1-abs(position))*(1-self.minimumAlpha))
attributes.alpha = alpha
let zIndex = (1-abs(position)) * 10
attributes.zIndex = Int(zIndex)
} else {
super.applyTransform(to: attributes)
}
}
}
thanks @closure11 it works.
and use this, if you want to specifically change the height of the left and right items...
let scaleX = max(1 - (1-self.minimumScale) * abs(position), self.minimumScale)
let scaleY = max(1 - (1-0.90) * abs(position), 0.90)
let transform = CGAffineTransform(scaleX: scaleX, y: scaleY)