简体   繁体   English

在iCarousel中,图像重叠。

[英]In iCarousel images are overlapping.

My code is below 我的代码如下

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
    UIImageView *imgView = nil;

    if (view == nil)
    {
        NSLog(@"no is %i",index);

        view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 255, 255)] autorelease];

        imgView = [[[UIImageView alloc] initWithImage:[ImagesCFArray objectAtIndex:index]] autorelease];

        [view addSubview:imgView];

    }

    else 
    {

    }

    return view;
}

ImagesCfArray contains the images to be displayed. ImagesCfArray包含要显示的图像。 0th index image overlapping with other images when carousel moves or scrolls. 轮播移动或滚动时,第0个索引图像会与其他图像重叠。 Please give me solution for this. 请给我解决方案。

Can you show your itemWidth implementation? 您可以显示itemWidth实现吗? Does it return more than 255? 返回值是否超过255?

You might want to tell the subview to clip to its bounds: 您可能要告诉子视图裁剪到其边界:

imgView.clipToBounds = YES;

And also, perhaps use a fill for the image: 而且,也许对图像使用填充:

imgView.contentMode = UIViewContentModeScaleAspectFit;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM