nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
http://www.charcoaldesign.co.uk/source/cocoa#icarousel
Other
12k stars 2.58k forks source link

constraints attribute? for optimizing for device size? #885

Open baalpeteor opened 5 years ago

baalpeteor commented 5 years ago

is there an attribute/tag to be called for altering constriants for optimization for device size? I have the below code but doesn't work using "iCarouselConstraint.constant" as this doesn't see to exist? The origina lcode was for changing the size of a static image.

The end goal is to have iCarousel resizing if it's an iphone 4/6 or ipad, so the app isn't bunched up (in my case play buttons) and the view fills out good. Thanks


    func optimizeForDeviceSize() {

        // Adjust album size to fit iPhone 4s, 6s & 6s+
        let deviceHeight = self.view.bounds.height

        if deviceHeight == 480 {
            iCarouselConstraint.constant = 106

            view.updateConstraints()
        } else if deviceHeight == 667 {
            iCarouselConstraint.constant = 230

            view.updateConstraints()
        } else if deviceHeight > 667 {
            iCarouselConstraint.constant = 260
            view.updateConstraints()
        }
    }