简体   繁体   English

UIView transitionWithView丢弃图层设置

[英]UIView transitionWithView discarding layer settings

I viewDidload I have settings like: 我viewDidload我有如下设置:

    [[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: 然后按下一个按钮,我正在做一个transitionWithView:viewPressed,如:

    [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是自定义视图,setImage设置其图层的内容,然后使用

[[self layer] setMasksToBounds:YES];

right after setCornerRadius it worked for me! 就在setCornerRadius之后, setCornerRadiussetCornerRadius

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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