【发布时间】:2011-12-09 19:44:14
【问题描述】:
我正在尝试将 UIView 作为附件视图添加到 UITextField,但似乎不尊重 alpha 属性。
这是我当前的代码。
self.keyboardAccView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
[self.keyboardAccView setBackgroundColor:[UIColor lightGrayColor]];
[self.keyboardAccView setOpaque:NO];
[self.keyboardAccView setAlpha:0.0];
UITapGestureRecognizer *hideKeyboardTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(hideKeyboard:)];
[self.keyboardAccView addGestureRecognizer:hideKeyboardTap];
[hideKeyboardTap release], hideKeyboardTap=nil;
alpha 值似乎无关紧要。无论我将其设置为什么,accessoryView 始终设置为不透明。
我想要完成的是在键盘上方显示一个透明视图,只要用户轻按键盘,它就会关闭键盘。如果有更好/正确的方法来做到这一点,我完全想念,我也全神贯注。
- 编辑 *
我知道我可以只使用 [UIColor clearColor] 作为背景颜色,但我更想知道为什么不支持 alpha 设置,以防我真的想要一个半透明的附件视图
【问题讨论】:
标签: iphone ios uiview accessoryview