需要显示动态宽度的项目。我试过波纹管代码。但它的物品之间的空间也越来越大。这是我的代码:
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{
UILabel *label = [[UILabel alloc]init];
label.font = [UIFont systemFontOfSize:13];
label.text = [timelineMediaArray objectAtIndex:index];
label.textAlignment = NSTextAlignmentCenter;
CGFloat width = [label.text sizeWithAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:13 ]}].width;
label.frame = CGRectMake(0, 0, width+20,30);
label.backgroundColor = [UIColor redColor];
label.textColor = [UIColor whiteColor];
return label;
}