简体   繁体   中英

UIView transitionWithView discarding layer settings

I viewDidload I have settings like:

    [[self layer] setCornerRadius:30.0f];
    NSString *imgFilepath = [[NSBundle mainBundle] pathForResource:@"imageName" ofType:@"jpeg"];
    backImg = [[UIImage alloc] initWithContentsOfFile:imgFilepath];

Then on a button pushed, I am doing a transitionWithView:viewPressed like:

    [UIView transitionWithView:viewPressed duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    animations:^{                            
                        [self setImage:img];
                        [self setFrame:useFrame]; // Just a bigger frame
                        [((UIView*)self) bringSubviewToFront:viewPressed];                            
                    }
                    completion:NULL];

I have nice rounded corners, but when the transition starts it gets square corners just before the animation.

Hope I am explaining this clear?

Thanks

What is self referring in the second code block?

i assumed that self is a custom view, setImage sets its layer's contents, then use

[[self layer] setMasksToBounds:YES];

right after setCornerRadius it worked for me!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM