3

Is it possible on iOS to make a regular UIView in some CGRect and add subviews to it and then tell that container UIView something like this:

containerView.layer.path = someClosedUIBezierPath

?

And will then all of the subviews also be curved according to it's parent container view?

I know that every UIView has it's own CALayer and that would be the starting point for me.

I saw examples with animations but I don't see nothing like above (maybe because it isn't there :))

vale4674
  • 4,161
  • 13
  • 47
  • 72
  • i didn't try this one but i think it should help: http://stackoverflow.com/a/10220145/653513 (it's done in `drawRect` though) – Rok Jarc Jul 26 '12 at 11:25
  • well that does not look very nice since I need user touches also. I thought it would be easy. – vale4674 Jul 26 '12 at 18:55

1 Answers1

7

This is a little late, but maybe it will help someone:

You can clip a view to a bezier path by using a CAShapeLayer and the view's layer's mask property:

CAShapeLayer shapeMask = [[CAShapeLayer alloc] initWithFrame:containerView.bounds];
shapeMask.path = someClosedUIBezierPath.CGPath;
containerView.layer.mask = shapeMask;
[shapeMask release];
Austin
  • 5,625
  • 1
  • 29
  • 43
  • Well, I use CAShapeLayer and mask but not for this problem. I decided not to push this problem and rearranged my UI. – vale4674 Oct 22 '12 at 21:08