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.
You should override and move your code to
loadView
to avoid having the auto layout engine generate prototyping constraints. For example:In general
loadView
is where you want to add subviews programmatically to aUIViewController
subclass.