2013-02-01 88 views

回答

0

UITapGestureRecognizer加到您的UIView。當您收到輕按時,請檢查您的識別器的locationInView:。如果輕敲發生在您想要進行輕擊的區域,觸發該操作;否則,忽略輕敲事件。

+3

如果您不需要解析精確的位置,您也可以簡單地在該區域上放置一個透明按鈕。 –

+0

輝煌。感謝熱舔和dasblinkenlight! – objectiveccoder001

+0

我剛剛實現了透明按鈕,完美的作品!同時啓用「隱藏」,只要我不希望它可點擊。 – objectiveccoder001

2

使用UITapGestureRecognizer,把透明的按鈕置於想要獲得

3

可點擊的部分區域添加自定義的UIButton在您看來,什麼都定位你需要點擊,然後對其執行 行動。

UIButton *button = [UIButton buttonWithType:0]; 
    [button setFrame:CGRectmake(0,0,0,0)]; //What ever clickable area, provide here 
    [button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];