DroidsOnRoids / SwiftCarousel

Lightweight, written natively in Swift, circular UIScrollView.
http://www.thedroidsonroids.com/blog/ios/circular-scroll-view-swiftcarousel/
MIT License
144 stars 43 forks source link

Placing Items Vertically Centered #34

Open dulimarta opened 8 years ago

dulimarta commented 8 years ago

I have images of same width but various heights that I'd like to place vertically centered in the carousel. The current settings are:

// For the carousel
myCarousel.resizeType = .WithoutResizing(1.0)

// For each image in the carousel
myImgView.contentMode = UIViewContentMode.ScaleAspectFit
myImgView.frame = CGRectMake (0, /* x-offset */
                              0, /* y-offset */ 
                              width, scaledHeight)

The issue is setting the y-offset to a non-zero would freeze the carousel to scroll.

I tried changing the image content mode to myImageView.contentMode = UIViewContentMode.Center, but the images would not scale correctly.

sunshinejr commented 8 years ago

Hey @dulimarta. Sorry for getting so late back to you. This is a bug because as of now there are few places where the y property is not really coded as it should. I will take a look at it in the next few days!