Comments (3)
Yes you can achieve this in few ways, the simplest one is just adjusting padding around your target view in the cell content view.
something like this:
func setup() {
// You can use Autolayout too
let cardFrame = CGRect(x: 0, y: 300, width: 100, height: 160)
card = UIView(frame: cardFrame)
card.backgroundColor = .gray
contentView.addSubview(card)
}
You also need to touch anchorPoint
since you want to keep items on the same base line so
class MyCell: UICollectionViewCell, ScaleTransformView {
var scaleOptions: ScaleTransformViewOptions {
.init(
minScale: 0.6,
scaleRatio: 0.4,
translationRatio: CGPoint(x: 0.66, y: 0)
)
}
func transform(progress: CGFloat) {
card.layer.anchorPoint = .init(x: 0.5, y: 1.5)
applyScaleTransform(progress: progress)
}
}
from collectionviewpaginglayout.
Thank you!
from collectionviewpaginglayout.
Finally I get what I need with this:
extension Cell: ScaleTransformView {
var scaleOptions: ScaleTransformViewOptions {
let minHeight: CGFloat = 220
let minScale = minHeight / Self.cardSize.height
let spacing: CGFloat = 16
let translationRatioXDelta = spacing / cardView.frame.width
return ScaleTransformViewOptions(
minScale: minScale,
scaleRatio: 1 - minScale,
translationRatio: CGPoint(x: minScale + translationRatioXDelta, y: 0)
)
}
func transform(progress: CGFloat) {
let leftInset: CGFloat = 20
let x = 0.5 - (leftInset / cardView.frame.width)
let height = Self.cardSize.height - cardView.frame.height
let y = 0.5 - (height / cardView.frame.height)
cardView.layer.anchorPoint = CGPoint(x: x, y: y)
applyScaleTransform(progress: progress)
}
}
from collectionviewpaginglayout.
Related Issues (20)
- swiftui ensure currentPage is greater than or equal to zero to prevent Index out of range error HOT 1
- Xcode 13.3 and swift version 5.6 Archiving issue ### HOT 1
- Hello, I encountered a problem with UI debugging or description during the development process HOT 1
- Vertical orientation of items HOT 1
- Suggestion for automatic looping scroll
- RTL support for layout HOT 2
- Using ScrollViewReader
- swiftUI use ScalePageView NavigationBar always showing HOT 12
- Strange SwiftUI navigation behavior when using CollectionViewPagingLayout HOT 1
- 新版为什么仅支持iOS13?? HOT 1
- Start on specific page in ScalePageView HOT 2
- How to handle button click event in cell with ScaleTransformView? HOT 1
- About Mac App HOT 2
- Compile time issue HOT 2
- Where is the LayoutDesigner sample app code hosted? HOT 1
- Question on memory leak HOT 1
- Is support objc?
- How to make the layout vertical instead of horizontal?
- TransformPageView RTL dragging is reversed
- View would blink and scrolling when the list changed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from collectionviewpaginglayout.