Alex
Alex

Reputation: 1448

Create UIView with custom shape

So I was wondering if there's a way to make a UIView with a custom shape.

I'm trying to make a piano keyboard so when the user touches the view a delegate method responds by playing a noise. The picture is a .png with the picture of the key and a transparent background.

Thanks in advance.

Upvotes: 0

Views: 1523

Answers (1)

Undo
Undo

Reputation: 25697

You can't make a UIView in the shape of, say, a triangle, but what you can do is make the view transparent, then add your non-transparent content to it.

For example, to make a view with a background of a png (with, I assume, partially transparent areas) you could make a transparent UIView and then add an image view to it. better yet, just use a UIImageView in the place.

Upvotes: 1

Related Questions