2012-05-14 60 views
1

成功顯示inputAccessoryView,但它是全黑的。設置UITextField的alpha值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; 

我對此完全困惑......任何人都可以解釋它爲什麼會發生?

回答

2

使用的UIColor對前行,而不是設置阿爾法這種方法: -

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

爽!感謝您的快速回復~~! – flypig