CGImageRef refImage1 = CGImageCreateWithImageInRect(image.CGImage, CGRectMake(0, image.size.height *0.5, image.size.width, image.size.height *0.5));
UIImage *image2 = [UIImage imageWithCGImage:refImage1];
UIImage *image2 = [UIImage imageWithCGImage:refImage1];
_myImage1.image = image2;
动画效果 :
if (_ishide == NO) {
_ishide = YES;
[UIView animateWithDuration:1 animations:^{
_myImage.frame = CGRectMake(0, -HEIGHT *0.5, WIDTH, HEIGHT *0.5);
_myImage1.frame = CGRectMake(0, HEIGHT, WIDTH, HEIGHT *0.5);
}];
}else
{
_ishide = NO;
[UIView animateWithDuration:1 animations:^{
_myImage.frame = CGRectMake(0, 0, WIDTH, HEIGHT *0.5);
_myImage1.frame = CGRectMake(0, HEIGHT *0.5, WIDTH, HEIGHT *0.5);
}];
}