Alexander Molodozhan
Alexander Molodozhan

Reputation: 25

Make clickable segments of irregular shape in iOS app

I want to make custom system to control some parameters of each room from iPad. I'd like to make each segments, which is shown on screenshoot, clickable, and the problem is that i don't understand how to make them clickable as buttons. Can somebody help with this task? I'm using Swift 4 and iPad Pro 9,7.

Building plan with coloured segments

Upvotes: 1

Views: 162

Answers (1)

Морт
Морт

Reputation: 1179

The native UIButton does not allow this. Your best bet would be to describe the plan as a set of CGPaths and hit test them.

You can have an UIView representing the floor plan, each room is a CGPath owned by the view and a custom UITapGestureRecognizer on the view that tests each of the CGPaths.

Upvotes: 1

Related Questions