iOS iCarousel图像偏移

iOS iCarousel图像偏移,ios,objective-c,image,icarousel,Ios,Objective C,Image,Icarousel,下午好。我在应用程序中使用的ICarusel。我有一个作为图像视图加载的图像。图像精确地放置在中心。请告诉我如何在不移动其余内容的情况下将图像移动到仅50像素 创建这样的视图的方法: - (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view { NSString *docDir = [NSHomeDirectory() stringB

下午好。我在应用程序中使用的ICarusel。我有一个作为图像视图加载的图像。图像精确地放置在中心。请告诉我如何在不移动其余内容的情况下将图像移动到仅50像素

创建这样的视图的方法:

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
    NSString *docDir = [NSHomeDirectory() stringByAppendingPathComponent:@"Library/Caches"];
    NSDictionary *myDic =[magazinesInfo objectAtIndex:index];

    //Resize image
    UIImage *img = [UIImage imageWithImage:[UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@_img.png",docDir,[myDic objectForKey:@"title"]]] scaledToSize:CGSizeMake(375,510)];

    UIImageView *romb = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 118, 135)];
    UIImageView *faceImage = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,768,1004)];
    UIImage *dwImage = [UIImage imageNamed:@"button.png"];
    UIImage *readImage = [UIImage imageNamed:@"read_button.png"];
    UIImage *deleteImage = [UIImage imageNamed:@"delete_button.png"];

    if(view ==nil)
    {

        UIButton *myDownloadButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
        [myDownloadButton setBackgroundColor:[UIColor blackColor]];
        [myDownloadButton setHidden:YES];


        romb.image = [UIImage imageNamed:@"romb.png"];

        view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 768, 1004)];
        [view setBackgroundColor:[UIColor blackColor]];
        view = faceImage;
        faceImage.image = nil;

        ((UIImageView *)view).image = nil;
        view.contentMode = UIViewContentModeCenter;


        //Magazine number
        myLabel = [[UILabel alloc] initWithFrame:CGRectMake(345, 85, 75, 29)];
        myLabel.backgroundColor = [UIColor clearColor];
        myLabel.textAlignment = NSTextAlignmentCenter;
        [myLabel setFont:[UIFont fontWithName:@"OpenSans-Light" size:36.0f]];
        myLabel.textColor = [UIColor whiteColor];
        myLabel.tag = 1;

        //Magazine name
        nameMag = [[UILabel alloc] initWithFrame:CGRectMake(-65, 450, 100, 100)];
        nameMag.backgroundColor = [UIColor yellowColor];
        nameMag.textAlignment = NSTextAlignmentCenter;
        [nameMag setFont:[UIFont fontWithName:@"OpenSans-Light" size:30.0f]];
        nameMag.textColor = [UIColor blackColor];
        nameMag.tag = 3;

        //Date
        dateMag = [[UILabel alloc] initWithFrame:CGRectMake(-67, 500, 500, 30)];
        dateMag.backgroundColor = [UIColor greenColor];
        dateMag.textAlignment = NSTextAlignmentCenter;
        [dateMag setFont:[UIFont fontWithName:@"OpenSans-Light" size:20.0f]];
        dateMag.textColor = [UIColor blackColor];
        dateMag.tag = 4;


        //Download button
        downloadButton = [[UIButton alloc] initWithFrame:CGRectMake(350, 700, 128, 37)];
        [downloadButton setBackgroundImage:dwImage forState:UIControlStateNormal];
        [downloadButton addTarget:self action:@selector(pressDownload:) forControlEvents:UIControlEventTouchUpInside];
        downloadButton.tag = 5;

        //Read button
        readButton = [[UIButton alloc] initWithFrame:CGRectMake(250, 750, 128, 37)];
        [readButton setBackgroundImage:readImage forState:UIControlStateNormal];
        [readButton addTarget:self action:@selector(readMag:) forControlEvents:UIControlEventTouchUpInside];
        readButton.hidden=YES;
        readButton.tag = 8;

        //Delete button
        deleteButton = [[UIButton alloc] initWithFrame:CGRectMake(400, 750, 128, 37)];
        [deleteButton setBackgroundImage:deleteImage forState:UIControlStateNormal];
        [deleteButton addTarget:self action:@selector(deleteMag:) forControlEvents:UIControlEventTouchUpInside];
        deleteButton.hidden=YES;
        deleteButton.tag = 9;

        //Progress bar
        downloadProgress  = [[UIProgressView alloc] initWithFrame:CGRectMake(100, 800, 127, 8)];
        downloadPrecent = [[UILabel alloc]initWithFrame:CGRectMake(300, 800, 8, 8)];
        downloadPrecent.backgroundColor = [UIColor blueColor];
        [downloadPrecent setFont:[UIFont fontWithName:@"OpenSans-Light" size:20.0f]];
        dateMag.textColor = [UIColor blackColor];
        downloadProgress.tag = 6;
        downloadPrecent.tag = 7;
        downloadProgress.hidden = YES;
        downloadPrecent.hidden = YES;



        //Add image subview
        [view addSubview:romb];

        //Label subview
        [view addSubview:myLabel];
        [view addSubview:nameMag];
        [view addSubview:dateMag];

        //Progressbar subview
        [view addSubview:downloadProgress];
        [view addSubview:downloadPrecent];

        //Buttons subview
        [view addSubview:downloadButton];
        [view addSubview:readButton];
        [view addSubview:deleteButton];
        [view addSubview:myDownloadButton];



    }

    else
    {

        romb.image = (UIImage*)[romb viewWithTag:3];
        ((UIImageView *)faceImage).image = (UIImage*)[view viewWithTag:2];


        myLabel = (UILabel *)[view viewWithTag:1];
        nameMag = (UILabel *)[view viewWithTag:3];
        dateMag = (UILabel *)[view viewWithTag:4];


        downloadProgress = (UIProgressView *) [view viewWithTag:6];
        downloadPrecent = (UILabel *)[view viewWithTag:7];



        downloadButton  = (UIButton *) [view viewWithTag:5];
        readButton  = (UIButton *) [view viewWithTag:8];
        deleteButton = (UIButton*) [view viewWithTag:9];



    }


        NSFileManager *fileManager = [NSFileManager defaultManager];
        NSLog(@"index is: %i",index);
        NSLog(@"current item index %i",[self.carousel currentItemIndex]);
        NSLog(@"%hhd",[fileManager fileExistsAtPath:[NSString stringWithFormat:@"%@/%@_mag.pdf",docDir,[myDic objectForKey:@"title"]]]);

        if ([fileManager fileExistsAtPath:[NSString stringWithFormat:@"%@/%@_mag.pdf",docDir,[myDic objectForKey:@"title"]]] == YES && (index == [self.carousel currentItemIndex]))
        {
            NSLog(@"%@",[[view subviews] objectAtIndex:9]);
            [[[view subviews] objectAtIndex:9] setHidden:NO];
            readButton.hidden = NO;
            deleteButton.hidden = NO;
            downloadButton.hidden = YES;
        }
        else
        {
            [[[view subviews] objectAtIndex:9] setHidden:YES];
            readButton.hidden = YES;
            deleteButton.hidden = YES;
            downloadButton.hidden = NO;

        }

    ((UIImageView *)view).image = img;
    myLabel.text = [myDic objectForKey:@"title"];
    dateMag.text = [myDic objectForKey:@"date"];
    romb.image = [UIImage imageNamed:@"romb.png"];


    return view;
}
现在看起来是这样的(别担心,它还在发展中:)

使用contentOffset属性相对于旋转木马视图移动旋转木马内容,而不更改其透视图


如果您想让viewpointOffset属性看起来像是透视图已更改(即从下方查看旋转木马),则可以使用viewpointOffset属性。

更改contentOffset或viewpointOffset不会导致结果。按指定值移动视图上的所有内容。我只需要移动图像,蓝色的形状留在原地。(我提供了一个链接,指向该应用程序现在的样子)