开发者

How to create a UIButton matrix that behaves like a UIKeyboard (Numberpad)?

开发者 https://www.devze.com 2023-02-01 06:35 出处:网络
Creating a simple button matrix with UIButtons is straight forward. What I\'m stuck with is the behavior of it. The multiple UIButtons b开发者_开发知识库ehave differently. The Keys on a UIKeyboard loo

Creating a simple button matrix with UIButtons is straight forward. What I'm stuck with is the behavior of it. The multiple UIButtons b开发者_开发知识库ehave differently. The Keys on a UIKeyboard loose their highlighted state when the touch leaves them, the custom ones keep their highlighted state for quite some time, even when the touch is outside.

Furthermore on the UIKeyboard one can drag the touch and thereby activate a different key, how would one implement this behavior with UIButtons in a Matrix setup?


To do something like the UIKeyboard I'd suggest not using UIButtons at all, and instead just use a UIView and use the touchesBegan: touchesEnded: touchesMoved: methods to determine where a user's finger is.

To select buttons as a finger moves around, you could have other views within the container that would be updated when the finger moves over it. This can be accomplished by doing hit tests as the finger moves around to see which UIView the user is over, then adjusting its visual state to show it.

0

精彩评论

暂无评论...
验证码 换一张
取 消