Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

custom iCarousel for Iphone? [closed]

In my app i want to implement an iCarousel for displaying view controllers like in the below image,i was gone through about many tutorials and links but iam not getting my requirement ,help me pleaseenter image description here

like image 941
Balu Avatar asked Nov 26 '12 05:11

Balu


3 Answers

It is known as coverflow in iOS. Follow this link you will get what you wanted and will come to know how to implement it.

Or you can refer this question on stack overflow too. and here is accepted answered of mine

like image 178
Janak Nirmal Avatar answered Nov 10 '22 07:11

Janak Nirmal


You can use iCarousel for the same effect

from below link download sample code for the carousel effect. https://github.com/nicklockwood/iCarousel

There is one example in No Nib Folder.

Open it & modify following code according to your requirement

//in iCarouselExampleViewController.m

In the below method modify there code as per your need.By adding different UI on the main view you can design your required UI.

In my case I have added one image & label on that main view.

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{

    UILabel *label = nil;
        UIImageView *imageLogo=nil;
        UIImageView *imageBack=nil;
    //create new view if no view is available for recycling
    if (view == nil)
    {
        view = [[[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"page1" ofType:@"png"]]] autorelease];
        imageBack=[[[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"3" ofType:@"png"]]] autorelease];
        imageBack.frame=CGRectMake(70, 70,388, 49);
        [view addSubview:imageBack];
        label = [[UILabel alloc]initWithFrame:CGRectMake(80, 78, 380, 30)];
        label.backgroundColor=[UIColor darkGrayColor];
        label.font = [label.font fontWithSize:20];
        label.backgroundColor=[UIColor clearColor];
        [view addSubview:label];
        imageLogo=[[[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Map" ofType:@"png"]]] autorelease];
        imageLogo.frame=CGRectMake(25, 70, 50, 49);
        [view addSubview:imageLogo];

    }
    else
    {
        label = [[view subviews] lastObject];
    }


    label.text = @"Some text";  

    label.frame=CGRectMake(label.frame.origin.x, label.frame.origin.y, label.frame.size.width,label.frame.size.height);

    return view;
    }

}
like image 2
svrushal Avatar answered Nov 10 '22 08:11

svrushal


iCarousel is used to display views, not view controllers.

There is no need to have an array of view controllers for what you are attempting to do - since all of your views behave the same way you can put your control logic in one view controller that manages the carousel and have any buttons in your carousel views call methods on your primary view controller, using the item index to determine which carousel item was pressed.

There are several example included with iCarousel that show how to do this, including the controls example which shows how to load individual carousel views from a nib file and bind their actions to the main view controller.

like image 2
Nick Lockwood Avatar answered Nov 10 '22 06:11

Nick Lockwood