合并期间图像应移至顶部

时间:2011-02-21 06:47:39

标签: iphone ipad

伙计们,  我正在开发一个项目,我在视图左侧和右侧的view.each imageView上放置了两个imagesViews。每个imageView包含两个图像,如image1和image2.I合并了两个视图并成功。合并后,image1在image2下。

我的要求是image2应该高于image1.can任何人都可以在这方面帮助我

提前预订

- (void) _playIntro
{
    _playing = YES;
    //merge halfway between the two magnets
    CGRect mergeFrame = kFunny123MagnetBoundsIntroIpad;
    mergeFrame.origin.x = (self.imageMagnet.frame.origin.x + self.glyphMagnet.frame.origin.x)/2;
    mergeFrame.origin.y = (self.imageMagnet.frame.origin.y + self.glyphMagnet.frame.origin.y)/2;

    [_imageMagnet mergeWithMagnet:_glyphMagnet  atFinalFrame:mergeFrame withDuration:kMagnetMergeDuration];

    //[_glyphMagnet mergeWithMagnet:_imageMagnet atFinalFrame:mergeFrame withDuration:kMagnetMergeDuration];
    [self performSelector:@selector(_introFinished) withObject:nil afterDelay:kMagnetMergeDuration + kAfterMagnetMergedDuration];
}


- (void) mergeWithMagnet:(Funny123MagnetView *)otherMagnet atFinalFrame:(CGRect)frame
            withDuration:(float)duration
{
    [UIView beginAnimations:@"merge" context:nil];
    [UIView setAnimationDuration:duration];
    BOOL showsTopImage;

    [self setFrame:[otherMagnet.superview convertRect:frame toView:self.superview]];
    [otherMagnet setFrame:frame];

    [UIView commitAnimations];

    [UIView beginAnimations:@"mergeFinalize" context:nil];
    [UIView setAnimationDuration:0.3];
    [UIView setAnimationDelay:duration];

    if (!showsTopImage)
    {
        [[otherMagnet _bottomImage] setAlpha:0];
        [[self _bottomImage] setAlpha:1];
        //[[otherMagnet _topImage] setAlpha:1];
        //[[self _topImage] setAlpha:0];
    }
    else {
        [[otherMagnet _topImage] setAlpha:1];
        [[self _topImage] setAlpha:0];

        //[[otherMagnet _bottomImage] setAlpha:0];
        //[[self _bottomImage] setAlpha:1];

    }


    [UIView commitAnimations];

}

_glyphImageView和_objectImageView是imageViews

1 个答案:

答案 0 :(得分:0)

我使用了sendSubViewToBack函数

[self.view sendSubViewToBack:self.imageMagnet]; 它工作了

你们所有人