我已將一個UIView
添加到視圖控制器的視圖。你說:如何使UIView的子視圖放置在UIView框架之外,是交互式的?
CGRect paneRect = {10.0f, 10.0f, 300.0f, 50.0f};
UIView *pane = [[UIView alloc] initWithFrame:paneRect];
pane.backgroundColor = [UIColor greenColor];
pane.userInteractionEnabled = YES;
pane.clipsToBounds = NO;
[self.view addSubview:pane];
然後我添加一個UIButton到pane
:
CGRect testRect = {10.0f, 25.0f, pane.frame.size.width - 20.0f, 50.0f};
UIButton *test = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[test setTitle:@"test" forState:UIControlStateNormal];
[test setFrame:testRect];
[pane addSubview:test];
現在一半的「測試」按鈕是窗格內,另一半超出。上半部分是互動的,並且對接觸做出反應,但下半部分不是。
是否有可能使整個「測試」按鈕,互動性和可觸摸,而不是它的一半?
您可以添加'test'到'self.view'無論如何,除非你有其他要求... – nhahtdh
具有u檢查我的答案 –
@DixitPatel嗨,我給你的答案嘗試但不解決問題。 – anonim