2011-09-12 28 views
0

我知道這很容易,但我還沒有發現任何關於它的事情。 我想要的是我如何獲得解釦的y位置?xcode:獲得u位置的uibutton

我希望任何人都可以提供幫助。 在此先感謝。

+0

可能重複的[如何獲取UI按鈕的x和y位置iPhone](http://stackoverflow.com/questions/2319642/how-to-get-the-x-and-y-position-of-a-ui-button-iphone) – progrmr

回答

5

由於UIButtonUIView一個子類,你可以簡單地使用

button.frame.origin.y 
+0

太好了,謝謝。 – Tanner

+2

@Tanner:最好在答案上投票,並表示接受,而不是感謝你;-) http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work –

0

或者你可以用更靈活的方式

CGRectGetMinY(button.frame) 

例如你可以在Y中期POS這樣

CGRectGetMidY(button.frame)