tags:

views:

195

answers:

1

I get the visibleRect from an UIImageView inside a method, that is called several times to move that view to the right. As soon as it goes partly out of the screen, I expect that the visibleRect becomes smaller. But it does not.

-(IBAction)moveToRight:(id)sender {
    CGRect frameRect = myUIImageView.frame; //that's an image I use in background of other views
    CALayer *myLayer = [myUIImageView layer];
    CGRect visRect = [myLayer visibleRect];

    NSLog(@"%f, %f", visRect.origin.x, visRect.size.width); //width is always 300.0

    CGPoint rectPoint = frameRect.origin;
    CGFloat newXPos = rectPoint.x + 10.5f;
    myUIImageView.frame = CGRectMake(newXPos, 0.0f, myUIImageView.frame.size.width, myUIImageView.frame.size.height);
}

is there something special I must think about, when I need the true visible Rectangle of an view? Actually I thought that it would be always clipped by the superview, so that method returns the true visible rectangle dimensions.

But as I move the UIImageView step by step to the right, it remains at 300.0 width. Even if a part of it goes out of the window.

+2  A: 

The only clipping that changes the visible rect is from a containing scroll layer.

Alex
Thanks. I wonder why Apple didn't mention it right away where they say that this cool Method is so useful ;)
Thanks
I have that same thought about every day with apple ;)
Alex