1
我想添加一个UIView作为accessoryView到UITextField,但alpha属性似乎并没有被尊重。在accessoryView上设置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]
作为的backgroundColor,但我更想知道为什么Alpha设置心不是兑现,万一我真的也想有一个半透明accessoryView的
我不使用XIB文件 – cpjolicoeur
哦,那就算了我的答案... –