0
我已經創建了自定義後臺欄按鈕。我添加了一個UIview,因爲我必須改變它的位置。很難點擊欄按鈕項目
UIImage *backButtonImage = [UIImage imageNamed:@"backBtnWhite"];
_backButton = [UIButton buttonWithType:UIButtonTypeCustom];
_backButton.exclusiveTouch = YES;
[_backButton setImage:backButtonImage forState:UIControlStateNormal];
[_backButton setImage:backButtonImage forState:UIControlStateHighlighted];
[_backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
_backButton.frame = CGRectMake(-4.0, 7.0, 40, 40);
UIView * view = [[UIView alloc] initWithFrame:CGRectMake(-4.0, 7.0, backButtonImage.size.width, backButtonImage.size.height)];
[view addSubview:_backButton];
UIBarButtonItem* barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:view];
self.navigationItem.rightBarButtonItem = barButtonItem;
但之後我添加了UIView變得很難點擊它。 我試圖改變按鈕區域,但它沒有給出結果。
更多描述請。 –
您將視圖的框架設置爲具有backButtonImage寬度和高度 - 是否在視圖實例化時正確設置了這些框架?此外,您可以嘗試確保視圖不吸收觸摸 – Alex