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

AutoLayout - Multipliers do not work on the iCarousel? #730

Open sharp999 opened 8 years ago

sharp999 commented 8 years ago

I am trying to use the multipliers on the iCarousel layout but they do not seem to have any affect at all. This is my code:

_carousel = [[iCarousel alloc]init ];
self.items = [NSMutableArray array];
for (int i = 0; i < 10; i++)
{
    [_items addObject:@(i)];
}
_carousel.type = iCarouselTypeCylinder;

_carousel.delegate = self;
_carousel.dataSource = self;

_carousel.translatesAutoresizingMaskIntoConstraints = false;

[self.view addSubview:_carousel];

[_carousel.centerXAnchor constraintEqualToAnchor:self.view.layoutMarginsGuide.centerXAnchor].active = true;
[_carousel.bottomAnchor constraintEqualToAnchor:self.view.layoutMarginsGuide.bottomAnchor constant:-80].active = true;

[_carousel.widthAnchor constraintEqualToAnchor:self.view.widthAnchor multiplier:40.0/100.0].active = true;
[_carousel.heightAnchor constraintEqualToAnchor:self.view.heightAnchor multiplier:30.0/100.0].active = true;

I have also noticed that if a input a constant value of the say -20 in:

[_carousel.bottomAnchor constraintEqualToAnchor:self.view.layoutMarginsGuide.bottomAnchor constant:-20].active = true;

the iCarousel drops well below the views bottom anchor and I don't know why?

Can anyone answer these please, forgive me if I've overlooked anything as I'am new to programmatic layouts.

TeksniOS commented 4 years ago

@sharp999 , I have the same issue but using Storyboard Auto layout. Did you solve this?