如何使用iCarousel进行菜单选择?

时间:2012-02-26 06:00:19

标签: ios plugins menu uibutton coverflow

我怎样才能使用iCarousel作为菜单按钮的替代品?我在想是否选择了第一个,然后背景会改变图像,如果选择第二个,背景会再次改变,依此类推。我试图实现这一点,但我a)不知道在哪里放它和b)不知道用什么来声明背景。

代码:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        wrap = NO;

        self.themes = [NSMutableArray arrayWithObjects:@"ball.png",
                        @"UFO.png",
                        nil];

        self.descriptions = [NSMutableArray arrayWithObjects:@"Theme: Original",
                             @"Theme: Space",
                             nil];
    }
    return self;
}

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
    return [themes count];
}

- (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel
{
    return 2;
}

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view
{
    view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[themes objectAtIndex:index]]];
    return view;
}

- (NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel
{
    return 0;
}

- (CGFloat)carouselItemWidth:(iCarousel *)carousel
{
    return 240;
}

- (BOOL)carouselShouldWrap:(iCarousel *)carousel
{
    return wrap;
}

- (void)carouselDidEndScrollingAnimation:(iCarousel *)Carousel
{
    [label setText:[NSString stringWithFormat:@"%@", [descriptions objectAtIndex:Carousel.currentItemIndex]]];
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSInteger rank = [userDefaults integerForKey:@"theme"];
    if (carousel.currentItemIndex == 0) {
        rank = 0;
    }
    if (carousel.currentItemIndex == 1) {
        rank = 1;
    }
}

最后一部分是我希望改变背景的地方。请让我知道你的想法,如果我需要更清楚,请告诉我。

0 个答案:

没有答案