1

当用户滑动应用程序介绍(PageViewController )时,我想red circle缓慢移动(如下图所示)(可能带有动画)。我还想添加一些动画,所以我尝试使用. 但目前我很难理解。有没有简单的方法来使用动画?或者有没有使用框架的教程?有人可以帮我吗?IFTTT/JazzHands frameworkPageViewControllerIFTTT/JazzHands

在此处输入图像描述

4

2 回答 2

1
Try this if its is ok vote for me


@interface homeViewController ()<UIScrollViewDelegate>

@property (weak, nonatomic) IBOutlet UIScrollView *scrollViewSlider;

@end

@implementation homeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationController.navigationBarHidden=true;
    [NSTimer scheduledTimerWithTimeInterval:4 target:self
    selector:@selector(scrollingTimer) userInfo:nil repeats:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/


-(void)viewDidLayoutSubviews
{
    UIImage *imageOne = [UIImage imageNamed:@"download.jpeg"];
    UIImage *imageTwo = [UIImage imageNamed:@"download2.jpeg"];
    UIImage *imageThree = [UIImage imageNamed:@"download3.jpeg"];
    UIImage *imageFour = [UIImage imageNamed:@"download4.jpeg"];

    NSArray *imageArray = [NSArray arrayWithObjects:imageOne,
                        imageTwo, imageThree, imageFour, nil];

    for (int i = 0; i <= 3; i++) {

        UIImageView *imgView = [[UIImageView alloc]init];
        imgView.contentMode = UIViewContentModeScaleToFill;
        imgView.alpha = 0.5f;
        imgView.frame = CGRectMake(i * self.scrollViewSlider.bounds.size.width,
                                    0, self.scrollViewSlider.bounds.size.width,
                                   self.scrollViewSlider.bounds.size.height);

        [imgView setImage:imageArray[i]];
        [self.scrollViewSlider addSubview:imgView];
        self.scrollViewSlider.pagingEnabled = true;

        [self.scrollViewSlider setContentSize:CGSizeMake(imageArray.count *
                                                                                                       self.scrollViewSlider.bounds.size.width,
                                                         self.scrollViewSlider.bounds.size.height-20)];


    }
}

-(void) scrollingTimer
{
    CGPoint frame =  self.scrollViewSlider.contentOffset;
    [UIView animateWithDuration:3.0f animations:^(void) {

        if (frame.x != 3 * self.scrollViewSlider.frame.size.width)

            [self.scrollViewSlider setContentOffset:CGPointMake(frame.x +

                                                            self.scrollViewSlider.frame.size.width, 0)];
        else

            [self.scrollViewSlider setContentOffset:CGPointMake(0, 0)];
    }];

     }
于 2016-02-01T05:02:04.260 回答
0

在没有任何第三方类的情况下尝试此代码,只需QuartzCore framwork从库中添加

#import <QuartzCore/QuartzCore.h>

- (CAAnimation*)movedown;
    {
        CABasicAnimation *animation = [CABasicAnimation animation];
        animation.keyPath = @"position.y";
        animation.fromValue = @600;
        animation.toValue = @50;
        animation.duration = 0.25;

        animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];

        [subView.layer addAnimation:animation forKey:@"basic"];    
        subView.layer.position = CGPointMake(0,-20);
        return animation;
    }

请替换您的动画视图subview

于 2016-02-01T04:29:03.627 回答