简体   繁体   English

单击UIButton时更改其位置

[英]Changing the location of a UIButton when it is clicked

I'm putting together an app that uses a keyboard (like the native iPhone one) that has symbols on the keys. 我正在整理一个使用键盘的应用程序(例如本机iPhone键盘),该键盘的按键上带有符号。 My question is how to I change the location of a button when it is clicked (as the UIControlStateHighlighted images is bigger than the regular state). 我的问题是如何在单击按钮时更改按钮的位置(因为UIControlStateHighlighted图像大于常规状态)。

Thanks for any help/pointers. 感谢您的帮助/指针。

All UIView instances have a frame, bounds, center, and transform properties. 所有UIView实例都具有框架,边界,居中和变换属性。 You can use any or all of these to manipulate your button. 您可以使用所有这些按钮中的任何一个或全部来操纵按钮。 Changing the center may be all you need to do. 更改中心可能只是您需要做的。

Try this: 尝试这个:

[yourView setFrame:CGRectMake(yourHorizontalPosition,yourVerticalPosition,[yourView.frame.size width],[yourView.frame.size height])];

Does that work for you? 那对你有用吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM