设置UITextField inputAccessoryView的alpha不起作用

时间:2012-05-14 09:41:43

标签: objective-c ios cocoa uitextfield

成功显示inputAccessoryView,但它完全是黑色的。

    _textField = [[UITextField alloc] initWithFrame: CGRectZero]; // update frame later
    _textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;

    UIView *inputAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 180)];
    inputAccessoryView.backgroundColor = [UIColor blackColor];
    inputAccessoryView.alpha = 0.2;

    _textField.inputAccessoryView = inputAccessoryView;

我对此完全感到困惑......任何人都能解释为什么会这样吗?

1 个答案:

答案 0 :(得分:2)

在前一行使用此UIColor方法,而不是设置alpha: -

[UIColor  colorWithHue:saturation:brightness:alpha:];