两个按钮(背景图不同)的翻转

UIButton *downButtonOne = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, self.bounds.size.width, 50)];

        [downButtonOne setImage:[UIImage imageNamed:@"main_advertisement1.png"] forState:UIControlStateNormal];

        [self addSubview:downButtonOne];

        

        UIButton *downButtonTwo = [UIButton buttonWithType:UIButtonTypeCustom];

        downButtonTwo.frame = CGRectMake(0, 0, self.bounds.size.width, 50);

        [downButtonTwo setImage:[UIImage imageNamed:@"main_advertisement.png"] forState:UIControlStateNormal];

        [self addSubview:downButtonTwo];

        [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(adAnimation) userInfo:nil repeats:YES];

- (void)adAnimation

{

    [UIView animateWithDuration:1.0 animations:^{

        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self cache:YES];

        [self exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    }];

}

原文地址:https://www.cnblogs.com/qianyindichang/p/3853432.html