vale4674
vale4674

Reputation: 4271

UIView that is shaped like a UIBezierPath?

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 :))

Upvotes: 3

Views: 3476

Answers (1)

Austin
Austin

Reputation: 5655

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];

Upvotes: 7

Related Questions