2

I am trying to flip a view and show a different view with an animation looking like flipping a card around.

This all worked well. I made one Parent View that nested 2 child views, these child views are the ones which get flipped. My Parent View has Rounded Corners through(layer.cornerRadius = x) and through layer.masksToBounds the child views don't go over the Bounds of the Parent view.

Anyway when I flip the views during this animation the corners are not rounded. I thought this is probably because when the flip happens the child views don't clip over the parent even with square corners, but then I also tried to add a cornerRadius to the Child Views which again did not work in my case because one of the Child Views nests itself child Views which then clip over the bounds again, which I don't understand at all!

I wrote a function to flip the views:

private func flip(firstView: UIView, secondView: UIView) {

     let transitionOptions: UIViewAnimationOptions = [.transitionFlipFromRight, .showHideTransitionViews]
    UIView.transition(with: firstView, duration: 1.0, options: transitionOptions, animations: {
        firstView.isHidden = !firstView.isHidden
    })

    UIView.transition(with: secondView, duration: 1.0, options: transitionOptions, animations: {
        secondView.isHidden = !secondView.isHidden
    })
}

For the rounded corners I just added a user defined runtime attribute in storyboard: layer.cornerRadius Number 13, as well as layer.masksToBounds Boolean true

I would really appreciate some help.

Thanks a lot!

  • could you maybe provide a minimal example that can be used to replicate the problem? – Milan Nosáľ Apr 04 '18 at 08:30
  • okay, just did that now, hope you can help –  Apr 04 '18 at 08:34
  • Not sure if it will work but try to set Clip to bounds on the parent view on IB. –  Apr 04 '18 at 08:39
  • tried that already but still the same problem –  Apr 04 '18 at 08:42
  • It almost seems like clip to bounds turns of during anmation or something similar to that, because when I round corners at one child that does not have children itself it works for this view but if I try the same for view that has children these children again dont clip to the bounds (and I cannot round corners to all children in my case) –  Apr 04 '18 at 08:44
  • @uhuru hey could you upvote this question if you cannot answer it? –  Apr 04 '18 at 12:12
  • @SirJoe yeah done, i tried myself a bit but couldn't find a solution for you sorry. let's see if someone else. –  Apr 04 '18 at 13:19
  • Thanks a lot though for trying –  Apr 04 '18 at 13:55
  • @MilanNosáľ hey could you upvote this question if you cannot answer it, would help a lot –  Apr 04 '18 at 13:56
  • @SirJoe When I was asking an example, I meant a complete code that could be compiled and run, ideally with a minimal code base (just the things necessary to replicate the issue) - playgrounds project maybe.. – Milan Nosáľ Apr 04 '18 at 13:58
  • Okay I am not near a computer right now but once I am I will do that –  Apr 04 '18 at 14:00

0 Answers0